Fix widget display on subgraph nodes (#4798)

This commit is contained in:
AustinMroz
2025-08-07 01:38:07 -05:00
committed by GitHub
parent f3b82e377a
commit 385c56d93d
2 changed files with 13 additions and 2 deletions

View File

@@ -1551,10 +1551,12 @@ export class LGraph
// Create subgraph node object
const subgraphNode = LiteGraph.createNode(subgraph.id, subgraph.name, {
inputs: structuredClone(inputs),
outputs: structuredClone(outputs)
})
if (!subgraphNode) throw new Error('Failed to create subgraph node')
for (let i = 0; i < inputs.length; i++) {
Object.assign(subgraphNode.inputs[i], inputs[i])
}
// Resize to inputs/outputs
subgraphNode.setSize(subgraphNode.computeSize())
@@ -1656,6 +1658,8 @@ export class LGraph
}
}
subgraphNode._setConcreteSlots()
subgraphNode.arrange()
return { subgraph, node: subgraphNode as SubgraphNode }
}

View File

@@ -72,7 +72,14 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
(e) => {
const subgraphInput = e.detail.input
const { name, type } = subgraphInput
if (this.inputs.some((i) => i.name == name)) return
const existingInput = this.inputs.find((i) => i.name == name)
if (existingInput) {
const linkId = subgraphInput.linkIds[0]
const { inputNode } = subgraph.links[linkId].resolve(subgraph)
const widget = inputNode?.widgets?.find?.((w) => w.name == name)
if (widget) this.#setWidget(subgraphInput, existingInput, widget)
return
}
const input = this.addInput(name, type)
this.#addSubgraphInputListeners(subgraphInput, input)