Skip to content

Commit

Permalink
fix(ui): copied edges must have new ids set
Browse files Browse the repository at this point in the history
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
  • Loading branch information
psychedelicious committed Jul 25, 2024
1 parent ba74737 commit bb876b8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb876b8

Please sign in to comment.