fix: Drag&Drop bug

This commit is contained in:
IlyaDoronin 2024-02-02 17:16:27 +03:00
parent 38c40d1dfe
commit d51d7ae44d

@ -167,14 +167,19 @@ export const reorderQuestions = (
setProducedState(
(state) => {
// Сортировка вопросов, что бы type: result были в конце для избежания багов
state.questions.sort((question, previousQuestion) =>
question.type === "result" && previousQuestion.type !== "result"
? 1
: question.type !== "result" && previousQuestion.type === "result"
? -1
: 0,
);
const [removed] = state.questions.splice(sourceIndex, 1);
state.questions.splice(destinationIndex, 0, removed);
},
{
type: "reorderQuestions",
sourceIndex,
destinationIndex,
},
{ type: "reorderQuestions", sourceIndex, destinationIndex },
);
updateQuestionOrders();