Skip to content

Commit bb876b8

Browse files
fix(ui): copied edges must have new ids set
Problems this was causing: - Deleting an edge was a copy of another edge deletes both edges - Deleting a node that was a copy-with-edges of another node deletes its edges and it's original edges, leaving what I will call "ghost noodles" behind
1 parent ba74737 commit bb876b8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ const pasteSelection = (withEdgesToCopiedNodes?: boolean) => {
5959
for (const edge of copiedEdges) {
6060
if (edge.source === node.id) {
6161
edge.source = id;
62-
edge.id = edge.id.replace(node.data.id, id);
63-
}
64-
if (edge.target === node.id) {
62+
} else if (edge.target === node.id) {
6563
edge.target = id;
66-
edge.id = edge.id.replace(node.data.id, id);
6764
}
6865
}
6966
node.id = id;
7067
node.data.id = id;
7168
});
7269

70+
copiedEdges.forEach((edge) => {
71+
// Copied edges need a fresh id too
72+
edge.id = uuidv4();
73+
});
74+
7375
const nodeChanges: NodeChange[] = [];
7476
const edgeChanges: EdgeChange[] = [];
7577
// Deselect existing nodes

0 commit comments

Comments
 (0)