From 0487dca3e3215776b7b5c692b235d2824b37fcdb Mon Sep 17 00:00:00 2001 From: StableLlama Date: Tue, 3 Nov 2026 23:10:11 +0100 Subject: [PATCH] Fix dynamic widget removal corrupting create DICT nodes (#65) Removing an empty dynamic input pair spliced node.widgets directly, which left the old entries in ComfyUI's widget value store. renumberDynamicInputs then renamed the inputs, but renaming the widgets silently failed because the target id was still taken by the orphaned entry. Input names and widget names drifted apart: the prompt was built from the stale widget names (key_1..value_2), so DictCreate.create() never found key_0 and returned {}, and the connected input link was drawn next to the wrong widget row. Remove widgets through node.removeWidget() so the store entry is deleted too, falling back to an array splice on older litegraph builds. Verified in ComfyUI 0.43 (frontend 1.57.4): clearing a pair now keeps inputs and widgets in sync, the link stays on its own row and the node returns the remaining pairs. --- web/js/dynamicnode.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/web/js/dynamicnode.js b/web/js/dynamicnode.js index a3b170c..fdb9aa4 100644 --- a/web/js/dynamicnode.js +++ b/web/js/dynamicnode.js @@ -218,9 +218,17 @@ app.registerExtension({ }; const removeWidgetForInput = (node, inputIdx) => { - if (node.inputs[inputIdx].widget && node.inputs[inputIdx].widget.name) { - const widgetName = node.inputs[inputIdx].widget.name; - const widgetIdx = node.widgets.findIndex((w) => w.name === widgetName); + const widgetName = node.inputs[inputIdx]?.widget?.name; + if (!widgetName) return; + const widget = node.widgets?.find((w) => w.name === widgetName); + if (!widget) return; + // Use the node API so ComfyUI's widget value store is cleaned up as well. + // A plain array splice leaves a stale store entry behind which blocks the + // rename in renumberDynamicInputs, desyncing widget names from input names. + if (typeof node.removeWidget === "function") { + node.removeWidget(widget); + } else { + const widgetIdx = node.widgets.indexOf(widget); if (widgetIdx !== -1) { node.widgets.splice(widgetIdx, 1); }