mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
fix: slot-promoted widgets not appearing/removing mid-session
The input-connected event was dispatched before the link was created, so the handler could not resolve the interior node via linkIds. Pass the node directly in the event detail. Widget disconnect used removeWidgetByName which failed for PromotedWidgetSlots (name mismatch). Use ensureWidgetRemoved with the direct widget reference instead. Amp-Thread-ID: https://ampcode.com/threads/T-019c5508-bf25-70e0-a48f-2663befeae98 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { INodeInputSlot } from '@/lib/litegraph/src/litegraph'
|
||||
import type { INodeInputSlot, LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
|
||||
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { LGraphEventMap } from './LGraphEventMap'
|
||||
export interface SubgraphInputEventMap extends LGraphEventMap {
|
||||
'input-connected': {
|
||||
input: INodeInputSlot
|
||||
node: LGraphNode
|
||||
widget: IBaseWidget
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ export class SubgraphInput extends SubgraphSlot {
|
||||
this._widget ??= inputWidget
|
||||
this.events.dispatch('input-connected', {
|
||||
input: slot,
|
||||
node,
|
||||
widget: inputWidget
|
||||
})
|
||||
}
|
||||
|
||||
@@ -211,19 +211,12 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
|
||||
const widget = subgraphInput._widget
|
||||
if (!widget) return
|
||||
|
||||
const widgetLocator = e.detail.input.widget
|
||||
// Resolve the interior node from the subgraph input's link
|
||||
const linkId = subgraphInput.linkIds[0]
|
||||
const link = linkId != null ? this.subgraph.getLink(linkId) : undefined
|
||||
const interiorNode = link?.resolve(this.subgraph).inputNode
|
||||
if (!interiorNode) return
|
||||
|
||||
this._setWidget(
|
||||
subgraphInput,
|
||||
input,
|
||||
widget,
|
||||
widgetLocator,
|
||||
interiorNode
|
||||
e.detail.input.widget,
|
||||
e.detail.node
|
||||
)
|
||||
},
|
||||
{ signal }
|
||||
@@ -236,7 +229,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
|
||||
const connectedWidgets = subgraphInput.getConnectedWidgets()
|
||||
if (connectedWidgets.length > 0) return
|
||||
|
||||
this.removeWidgetByName(input.name)
|
||||
if (input._widget) this.ensureWidgetRemoved(input._widget)
|
||||
|
||||
delete input.pos
|
||||
delete input.widget
|
||||
|
||||
Reference in New Issue
Block a user