[Bug] Fix remove of floatingLinks (#792)

Resolves https://github.com/Comfy-Org/litegraph.js/issues/791

This PR fixes removal of floating links.

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
This commit is contained in:
Chenlei Hu
2025-03-16 18:13:24 -04:00
committed by GitHub
parent dbc605e4da
commit 94b9ecec71
5 changed files with 96 additions and 1 deletions

View File

@@ -900,6 +900,13 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
}
}
// Floating links
for (const link of this.floatingLinks.values()) {
if (link.origin_id === node.id || link.target_id === node.id) {
this.removeFloatingLink(link)
}
}
// callback
node.onRemoved?.()
@@ -1401,6 +1408,10 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
if (reroute.floatingLinkIds.size === 0) {
delete reroute.floating
}
if (reroute.floatingLinkIds.size === 0 && reroute.linkIds.size === 0) {
this.removeReroute(reroute.id)
}
}
}