From bb876b8d4e31aacb3f89730bbc558e57cf8ee3e9 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:19:03 +1000 Subject: [PATCH] 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 --- .../web/src/features/nodes/hooks/useCopyPaste.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts b/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts index 32db806cde..2a2bfde904 100644 --- a/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts +++ b/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts @@ -59,17 +59,19 @@ const pasteSelection = (withEdgesToCopiedNodes?: boolean) => { for (const edge of copiedEdges) { if (edge.source === node.id) { edge.source = id; - edge.id = edge.id.replace(node.data.id, id); - } - if (edge.target === node.id) { + } else if (edge.target === node.id) { edge.target = id; - edge.id = edge.id.replace(node.data.id, id); } } node.id = id; node.data.id = id; }); + copiedEdges.forEach((edge) => { + // Copied edges need a fresh id too + edge.id = uuidv4(); + }); + const nodeChanges: NodeChange[] = []; const edgeChanges: EdgeChange[] = []; // Deselect existing nodes