From 6d3865d4ec546cbc865ca4d9632fa0524384004d Mon Sep 17 00:00:00 2001 From: skeris Date: Mon, 4 Dec 2023 00:54:44 +0300 Subject: [PATCH] fix: when you try to grow ManOfGraph, when you add lust leg, both of them bursts --- src/pages/Questions/AnswerDraggableList/AnswerItem.tsx | 2 +- src/pages/Questions/BranchingMap/CsComponent.tsx | 6 +++--- .../Questions/BranchingModal/BranchingQuestionsModal.tsx | 1 + src/pages/Questions/BranchingModal/Settings.tsx | 4 ++-- src/pages/Questions/BranchingQuestionsModal/index.tsx | 5 ++++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx index 5ccb0a98..6cb8562e 100644 --- a/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx +++ b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx @@ -1,7 +1,7 @@ import { MessageIcon } from "@icons/messagIcon"; import { PointsIcon } from "@icons/questionsPage/PointsIcon"; import { DeleteIcon } from "@icons/questionsPage/deleteIcon"; -import TextareaAutosize from "@mui/base/TextareaAutosize"; +import { TextareaAutosize } from "@mui/base/TextareaAutosize"; import { Box, FormControl, diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index 6cdc66d9..afb5317b 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -331,16 +331,17 @@ console.log(e.cy.data('firstNode'),"SKEEER",e.cy.data('changed')) while (queue.length) { const task = queue.pop() task.task.data('layer', task.layer) - console.log('SAMSHIIIIT',task.layer,task.task.data().layer) + task.task.removeData('subtreeWidth') const children = e.cy().edges(`[source="${task.task.id()}"]`).targets() task.task.data('children', children.length) if (children.length !== 0) { children.forEach(n => queue.push({ task: n, layer: task.layer + 1 })) } } - queue.push({ parent: e, children: children.targets() }) + queue.push({ parent: e, children: children }) while (queue.length) { const task = queue.pop() +console.log('WIIIING',task.parent.data(),task.children.length) if (task.children.length === 0) { task.parent.data('subtreeWidth', task.parent.height()) continue @@ -363,7 +364,6 @@ console.log(e.cy.data('firstNode'),"SKEEER",e.cy.data('changed')) e.data('oldPos', pos) return pos } else { -console.log(e.cy().data('firstNode')) if (e.cy().data('firstNode') !== 'root') { e.cy().data('firstNode','nonroot') return {x:0,y:0} diff --git a/src/pages/Questions/BranchingModal/BranchingQuestionsModal.tsx b/src/pages/Questions/BranchingModal/BranchingQuestionsModal.tsx index 0c140f52..206e7168 100644 --- a/src/pages/Questions/BranchingModal/BranchingQuestionsModal.tsx +++ b/src/pages/Questions/BranchingModal/BranchingQuestionsModal.tsx @@ -37,6 +37,7 @@ export default function BranchingQuestions() { console.log(parentQuestion) useLayoutEffect(() => { + if (parentQuestion === null) return if (parentQuestion.content.rule.main.length === 0) updateQuestion(parentQuestion.id, question => question.content.rule.main.push({ next: targetQuestion.content.id, or: true, diff --git a/src/pages/Questions/BranchingModal/Settings.tsx b/src/pages/Questions/BranchingModal/Settings.tsx index 8322b442..7de6cc51 100644 --- a/src/pages/Questions/BranchingModal/Settings.tsx +++ b/src/pages/Questions/BranchingModal/Settings.tsx @@ -148,7 +148,7 @@ const SelectorType = ({ parentQuestion, targetQuestion, ruleIndex, setParentQues