Merge pull request #55 from danuryx/fix-widget-index

Fix: look widgets up by name instead of hardcoded indices in show() (editor crash on open)
This commit is contained in:
mhstar
2026-07-19 14:18:07 -05:00
committed by GitHub
+11 -4
View File
@@ -98,15 +98,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;