From 32b6b7eff92a7bdceb7b8febb35461fc7c8bb3c5 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Tue, 4 Mar 2025 06:16:55 +1100 Subject: [PATCH] Fix reroutes lost when moving links via outputs (#699) - Resolves #309 https://github.com/user-attachments/assets/70c8b9ba-b4e6-4293-a254-6ae95930d1f1 --- src/LGraphCanvas.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index b2c311ceb..0ddf61844 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -2236,7 +2236,8 @@ export class LGraphCanvas implements ConnectionColorContext { if (isInRectangle(x, y, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) { // Drag multiple output links if (e.shiftKey && output.links?.length) { - this.connecting_links = [] + const connectingLinks: ConnectingLink[] = [] + for (const linkId of output.links) { const link = graph._links.get(linkId) if (!link) continue @@ -2245,18 +2246,21 @@ export class LGraphCanvas implements ConnectionColorContext { const otherNode = graph._nodes_by_id[link.target_id] const input = otherNode.inputs[slot] const pos = otherNode.getConnectionPos(true, slot) + const firstRerouteId = LLink.getReroutes(graph, link).at(0)?.id - this.connecting_links.push({ + connectingLinks.push({ node: otherNode, slot, input, output: null, pos, direction: LinkDirection.RIGHT, + afterRerouteId: firstRerouteId, link, }) } + this.connecting_links = connectingLinks return }