diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index 3486b200..16252bb6 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -178,17 +178,16 @@ export const CsComponent = ({ console.log("remove") const cy = cyRef?.current - const targetQuestionContentId = cy?.$('#' + targetNodeContentId)?.data().id - const a = getQuestionByContentId(targetNodeContentId) console.log(a) - console.log(a) - console.log(targetQuestionContentId) + console.log(a.content) + console.log(a.content.rule.parentId) + console.log(a.content.rule.parentId === "root") console.log(targetNodeContentId) if (a.content.rule.parentId === "root" && quiz) { console.log("click ROOT") - updateQuestion(targetQuestionContentId, question => { + updateQuestion(targetNodeContentId, question => { question.content.rule.parentId = "" question.content.rule.main = [] question.content.rule.default = "" @@ -197,9 +196,9 @@ export const CsComponent = ({ } else { console.log("click not ROOT") const parentQuestionContentId = cy?.$('edge[target = "' + targetNodeContentId + '"]')?.toArray()?.[0]?.data()?.source - if (targetQuestionContentId && parentQuestionContentId) { + if (targetNodeContentId && parentQuestionContentId) { - clearDataAfterRemoveNode({ targetQuestionContentId, parentQuestionContentId }) + clearDataAfterRemoveNode({ targetQuestionContentId: targetNodeContentId, parentQuestionContentId }) cy?.remove(cy?.$('#' + targetNodeContentId)).layout(lyopts).run() } diff --git a/src/pages/Questions/BranchingMap/FirstNodeField.tsx b/src/pages/Questions/BranchingMap/FirstNodeField.tsx index d482f6ab..159dfbeb 100644 --- a/src/pages/Questions/BranchingMap/FirstNodeField.tsx +++ b/src/pages/Questions/BranchingMap/FirstNodeField.tsx @@ -38,12 +38,12 @@ export const FirstNodeField = ({ setOpenedModalQuestions, modalQuestionTargetCon Container.current?.removeEventListener("mouseup", newRootNode) Container.current?.removeEventListener("click", modalOpen) } - }, []) + }, [dragQuestionContentId]) useEffect(() => { if (quiz) { - if (dragQuestionContentId) { + if (modalQuestionTargetContentId) { updateRootInfo(quiz?.id, true) updateQuestion(modalQuestionTargetContentId, (question) => question.content.rule.parentId = "root") }