fix: wrong socket was highlighted when dragging node

The old code had a bug that highlighted a socket from a node to which a
edge already exists which could not be connected to
This commit is contained in:
2026-02-07 15:52:18 +01:00
parent 8ad9e5535c
commit bafbcca2b8
3 changed files with 362 additions and 7 deletions

View File

@@ -757,12 +757,16 @@ export class GraphManager extends EventEmitter<{
(n) => n.id !== node.id && !parents.has(n.id)
);
// get edges from this socket
const edges = new SvelteMap(
this.getEdgesFromNode(node)
.filter((e) => e[1] === index)
.map((e) => [e[2].id, e[3]])
);
const edges = new SvelteMap<number, string[]>();
this.getEdgesFromNode(node)
.filter((e) => e[1] === index)
.forEach((e) => {
if (edges.has(e[2].id)) {
edges.get(e[2].id)?.push(e[3]);
} else {
edges.set(e[2].id, [e[3]]);
}
});
const ownType = nodeType.outputs?.[index];
@@ -775,7 +779,7 @@ export class GraphManager extends EventEmitter<{
if (
areSocketsCompatible(ownType, otherType)
&& edges.get(node.id) !== key
&& !edges.get(node.id)?.includes(key)
) {
sockets.push([node, key]);
}