Skip to content

Commit a850f3e

Browse files
committed
fix: 새로운 pages로 노드 업데이트하게 수정
1 parent 974f504 commit a850f3e

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

frontend/src/components/canvas/index.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ function Flow({ className }: CanvasProps) {
9191
}
9292
const newNodes = [...nds];
9393
newNodes[index] = {
94-
...newNodes[index],
95-
position: updatedNode.position,
96-
selected: false,
94+
...updatedNode,
95+
selected: newNodes[index].selected,
9796
};
9897
return newNodes;
9998
});
@@ -131,21 +130,19 @@ function Flow({ className }: CanvasProps) {
131130
const pageId = page.id.toString();
132131
const existingNode = nodesMap.get(pageId) as Node | undefined;
133132

134-
if (!existingNode) {
135-
const newNode = {
136-
id: pageId,
137-
type: "note",
138-
data: { title: page.title, id: page.id },
139-
position: {
140-
x: Math.random() * 500,
141-
y: Math.random() * 500,
142-
},
143-
selected: false,
144-
};
145-
146-
nodesMap.set(pageId, newNode);
147-
existingPageIds.current.add(pageId);
148-
}
133+
const newNode = {
134+
id: pageId,
135+
type: "note",
136+
data: { title: page.title, id: page.id },
137+
position: existingNode?.position || {
138+
x: Math.random() * 500,
139+
y: Math.random() * 500,
140+
},
141+
selected: false,
142+
};
143+
144+
nodesMap.set(pageId, newNode);
145+
existingPageIds.current.add(pageId);
149146
});
150147
}, [pages, ydoc]);
151148

0 commit comments

Comments
 (0)