From fef6ef6c2c6970a4785199b3b59cfe56123194f5 Mon Sep 17 00:00:00 2001 From: jessesep Date: Fri, 5 Dec 2025 02:12:50 +0100 Subject: [PATCH] Fix: capture node reference for dropdown callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'this' context was wrong inside the values callback. Now uses 'node' reference like KJNodes does. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- web/simplevariables.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/web/simplevariables.js b/web/simplevariables.js index 1e633b9..c63e047 100644 --- a/web/simplevariables.js +++ b/web/simplevariables.js @@ -92,13 +92,23 @@ app.registerExtension({ this.properties = this.properties || {}; this.properties.variableName = ""; + const node = this; + // Variable name dropdown (shows available setters) this.addWidget("combo", "name", "", (value) => { - this.properties.variableName = value; - this.title = value ? `Get: ${value}` : "Get Variable"; - this.syncWithSetter(); + node.properties.variableName = value; + node.title = value ? `Get: ${value}` : "Get Variable"; + node.syncWithSetter(); }, { - values: () => this.getAvailableVariables() + values: () => { + if (!node.graph) return [""]; + const setters = node.graph._nodes.filter(n => n.type === "SetVariableNode"); + const names = setters + .map(n => n.properties?.variableName || n.widgets?.[0]?.value || "") + .filter(n => n !== "") + .sort(); + return ["", ...names]; + } }); this.addOutput("value", "*"); @@ -110,16 +120,6 @@ app.registerExtension({ this.isVirtualNode = true; } - getAvailableVariables() { - if (!this.graph) return [""]; - const setters = this.graph._nodes.filter(n => n.type === "SetVariableNode"); - const names = setters - .map(n => n.properties?.variableName || n.widgets?.[0]?.value || "") - .filter(n => n !== "") - .sort(); - return ["", ...names]; - } - findSetter() { if (!this.graph || !this.properties.variableName) return null; const name = this.properties.variableName;