From 75d7a3725bb6217e0458f0f7204df40d9776106f Mon Sep 17 00:00:00 2001 From: AustinMroz Date: Mon, 18 Aug 2025 18:25:39 -0500 Subject: [PATCH] Fix widgets added after previews on subgraph nodes (#5084) Image previews are displayed on nodes as a widget. If a new input is added to a subgraph that already has an image preview, that widget is incorrectly placed after the preview. This is fixed by instead counting the number of existing inputs that are already linked to widgets. --- src/lib/litegraph/src/subgraph/SubgraphNode.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/litegraph/src/subgraph/SubgraphNode.ts b/src/lib/litegraph/src/subgraph/SubgraphNode.ts index 8ee6dcdc6..d87e49658 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphNode.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphNode.ts @@ -361,7 +361,8 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { } }) - this.widgets.push(promotedWidget) + const widgetCount = this.inputs.filter((i) => i.widget).length + this.widgets.splice(widgetCount, 0, promotedWidget) // Dispatch widget-promoted event this.subgraph.events.dispatch('widget-promoted', {