Fix DOM widgets disappear

This commit is contained in:
filtered
2025-05-15 08:37:21 +10:00
parent 3f5113f49d
commit 9541735bef

View File

@@ -787,26 +787,29 @@ export class ComfyApp {
LiteGraph.alt_drag_do_clone_nodes = true LiteGraph.alt_drag_do_clone_nodes = true
LiteGraph.macGesturesRequireMac = false LiteGraph.macGesturesRequireMac = false
this.canvas.canvas.addEventListener('litegraph:set-graph', (e) => { this.canvas.canvas.addEventListener<'litegraph:set-graph'>(
type SetGraphType = CustomEvent<{ 'litegraph:set-graph',
newGraph: LGraph | Subgraph (e) => {
oldGraph: LGraph | Subgraph // Assertion: Not yet defined in litegraph.
}> const { newGraph } = e.detail
// Assertion: Not yet defined in litegraph. const nodeSet = new Set(newGraph.nodes)
const { newGraph } = (e as SetGraphType).detail const widgetStore = useDomWidgetStore()
const nodeSet = new Set(newGraph.nodes)
const widgetStore = useDomWidgetStore()
for (const { widget } of widgetStore.widgetStates.values()) {
// Assertions: UnwrapRef // Assertions: UnwrapRef
if (nodeSet.has(widget.node as LGraphNode)) { for (const { widget } of widgetStore.widgetStates.values()) {
widgetStore.registerWidget(widget as BaseDOMWidget) if (!nodeSet.has(widget.node as LGraphNode)) {
} else { widgetStore.unregisterWidget(widget.id)
widgetStore.unregisterWidget(widget.id) }
}
for (const { widget } of widgetStore.inactiveWidgetStates.values()) {
if (nodeSet.has(widget.node as LGraphNode)) {
widgetStore.registerWidget(widget as BaseDOMWidget)
}
} }
} }
}) )
this.graph.start() this.graph.start()