From bd36b4b72565b527325a627881506e10d1c9052b Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 19 Mar 2026 15:34:01 +0100 Subject: [PATCH] fix: prevent undefined in combo widgets with empty values Combo widgets show "undefined" when values list is empty. Now ensures at least one entry (empty string placeholder) and picks a valid default. Also populates source labels immediately on node creation. Co-Authored-By: Claude Opus 4.6 --- web/project_key.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/project_key.js b/web/project_key.js index 9bf383a..7a560bf 100644 --- a/web/project_key.js +++ b/web/project_key.js @@ -33,10 +33,13 @@ app.registerExtension({ if (idx === -1 || idx === undefined) return null; const oldWidget = node.widgets[idx]; const savedValue = oldWidget.value || ""; + // Ensure values list is never empty (combo shows undefined otherwise) + const comboValues = values.length > 0 ? values : [""]; + const defaultValue = comboValues.includes(savedValue) ? savedValue : comboValues[0]; // Remove old STRING widget node.widgets.splice(idx, 1); // Insert a real combo widget at the same position - const combo = node.addWidget("combo", name, savedValue, callback, { values: values }); + const combo = node.addWidget("combo", name, defaultValue, callback, { values: comboValues }); // Move it from the end to the original position if (node.widgets.length > 1) { node.widgets.splice(node.widgets.length - 1, 1); @@ -58,15 +61,19 @@ app.registerExtension({ // Replace source_label STRING with a proper combo widget const node = this; - replaceWithCombo(this, "source_label", [], function (value) { + const sourceLabels = this._getSourceLabels?.() || []; + const srcCombo = replaceWithCombo(this, "source_label", sourceLabels, function (value) { node._syncFromSource(); node._refreshKeys(); }); + // Set first available source or "none" placeholder + if (srcCombo) srcCombo.value = sourceLabels[0] || ""; // Replace key_name STRING with a proper combo widget - replaceWithCombo(this, "key_name", [], function (value) { + const keyCombo = replaceWithCombo(this, "key_name", [], function (value) { node._applyKeySelection(); }); + if (keyCombo) keyCombo.value = ""; queueMicrotask(() => { if (!this._configured) {