Fix: capture node reference for dropdown callback

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 <noreply@anthropic.com>
This commit is contained in:
jessesep
2025-12-05 02:12:50 +01:00
co-authored by Claude
parent d2a4ffdd3b
commit fef6ef6c2c
+14 -14
View File
@@ -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;