diff --git a/src/LGraph.ts b/src/LGraph.ts index 082e7c10f..4568bd20a 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -1250,7 +1250,10 @@ export class LGraph implements LinkNetwork, Serialisable { const linkIds = before instanceof Reroute ? before.linkIds : [before.id] - const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds) + const floatingLinkIds = before instanceof Reroute + ? before.floatingLinkIds + : [before.id] + const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds, floatingLinkIds) this.reroutes.set(rerouteId, reroute) for (const linkId of linkIds) { const link = this._links.get(linkId) @@ -1263,6 +1266,17 @@ export class LGraph implements LinkNetwork, Serialisable { } } + for (const linkId of floatingLinkIds) { + const link = this.floatingLinks.get(linkId) + if (!link) continue + if (link.parentId === before.parentId) link.parentId = rerouteId + + const reroutes = LLink.getReroutes(this, link) + for (const x of reroutes.filter(x => x.parentId === before.parentId)) { + x.parentId = rerouteId + } + } + return reroute }