From 7640c32830af06ee3a7976eb03b4f4fa7075a00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Otgaar?= Date: Tue, 2 Dec 2025 12:47:38 +0100 Subject: [PATCH] fix: fix the creation of new phases so that the data is deepcloned instead of referenced --- .../visualProgrammingUI/components/DragDropSidebar.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx b/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx index fb4857e..e02f81a 100644 --- a/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx +++ b/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx @@ -56,7 +56,7 @@ function addNode(nodeType: keyof typeof NodeTypes, position: XYPosition) { // Find out if there's any default data about our ndoe const defaultData = NodeDefaults[nodeType] ?? {} - + // Currently, we find out what the Id is by checking the last node and adding one const sameTypeNodes = nodes.filter((node) => node.type === nodeType); const nextNumber = @@ -75,7 +75,9 @@ function addNode(nodeType: keyof typeof NodeTypes, position: XYPosition) { id: id, type: nodeType, position, - data: {...defaultData} + // Deep copy using JSON because thats how things work: + // Ref: https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy + data: structuredClone(defaultData) } setNodes([...nodes, newNode]); }