Skip to content

Commit 385c56d

Browse files
authored
Fix widget display on subgraph nodes (#4798)
1 parent f3b82e3 commit 385c56d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/lib/litegraph/src/LGraph.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,10 +1551,12 @@ export class LGraph
15511551

15521552
// Create subgraph node object
15531553
const subgraphNode = LiteGraph.createNode(subgraph.id, subgraph.name, {
1554-
inputs: structuredClone(inputs),
15551554
outputs: structuredClone(outputs)
15561555
})
15571556
if (!subgraphNode) throw new Error('Failed to create subgraph node')
1557+
for (let i = 0; i < inputs.length; i++) {
1558+
Object.assign(subgraphNode.inputs[i], inputs[i])
1559+
}
15581560

15591561
// Resize to inputs/outputs
15601562
subgraphNode.setSize(subgraphNode.computeSize())
@@ -1656,6 +1658,8 @@ export class LGraph
16561658
}
16571659
}
16581660

1661+
subgraphNode._setConcreteSlots()
1662+
subgraphNode.arrange()
16591663
return { subgraph, node: subgraphNode as SubgraphNode }
16601664
}
16611665

src/lib/litegraph/src/subgraph/SubgraphNode.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
7272
(e) => {
7373
const subgraphInput = e.detail.input
7474
const { name, type } = subgraphInput
75-
if (this.inputs.some((i) => i.name == name)) return
75+
const existingInput = this.inputs.find((i) => i.name == name)
76+
if (existingInput) {
77+
const linkId = subgraphInput.linkIds[0]
78+
const { inputNode } = subgraph.links[linkId].resolve(subgraph)
79+
const widget = inputNode?.widgets?.find?.((w) => w.name == name)
80+
if (widget) this.#setWidget(subgraphInput, existingInput, widget)
81+
return
82+
}
7683
const input = this.addInput(name, type)
7784

7885
this.#addSubgraphInputListeners(subgraphInput, input)

0 commit comments

Comments
 (0)