mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Fix widget display on subgraph nodes (#4798)
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user