From effcee0069d22dd5d90031c80ac9029ebf878e55 Mon Sep 17 00:00:00 2001 From: Daniel Hernandez Ramos Date: Sun, 19 Jul 2026 00:17:25 -0600 Subject: [PATCH] Fix: look widgets up by name instead of hardcoded indices in show() --- js/openpose_editor.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/openpose_editor.js b/js/openpose_editor.js index d8a6910..b032379 100644 --- a/js/openpose_editor.js +++ b/js/openpose_editor.js @@ -88,15 +88,22 @@ class OpenposeEditorDialog extends ComfyDialog { } const targetNode = ComfyApp.clipspace_return_node; - if (targetNode.inputs?.[0].link || targetNode.inputs?.[targetNode.inputs.length-1].widget){ - const textAreaElement = targetNode.widgets[15].element; + // Fix #49/#45: look widgets up by name instead of hardcoded indices. + // Depending on the frontend version, POSE_KEYPOINT may be a socket-only + // input with no widget, so widgets[15] can be undefined and reading + // .element crashes the editor before it opens. + const jsonWidget = targetNode.widgets.find(w => w.name === "POSE_JSON"); + const keypointWidget = targetNode.widgets.find(w => w.name === "POSE_KEYPOINT"); + const hasKeypointInput = targetNode.inputs?.[0].link || targetNode.inputs?.[targetNode.inputs.length-1].widget; + if (hasKeypointInput && keypointWidget?.element){ + const textAreaElement = keypointWidget.element; this.element.style.display = "flex"; this.setCanvasJSONString(textAreaElement.value.replace(/'/g, '"')); } else { - const textAreaElement = targetNode.widgets[14].element; + const textAreaElement = jsonWidget.element; this.element.style.display = "flex"; if (textAreaElement.value === "") { - let resolution_x = targetNode.widgets[3].value; + let resolution_x = targetNode.widgets.find(w => w.name === "resolution_x")?.value ?? -1; let resolution_y = Math.floor(768*(resolution_x*1.0/512)); if (resolution_x < 64){ resolution_x = 512;