Skip to content

Commit 4be66d7

Browse files
authored
FIX: Support new 'element' prop in comfyui frontend
The new comfyui-frontend versions don't use the 'inputEl' prop anymore, they use 'element' prop. This change supports the new prop and is backwards compatible
1 parent 7d8190e commit 4be66d7

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

web/js/main.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,21 @@ function initializeEventHandlers() {
5050
ComfyWidgets.STRING = function (node, inputName, inputData, appInstance) { // Use appInstance to avoid conflict with global app
5151
const result = originalStringWidget.apply(this, arguments);
5252

53-
// Check if the widget has an inputEl and if it's a TEXTAREA
53+
// Check if the widget has an element and if it's a TEXTAREA
5454
// This is to ensure we are targeting multiline text inputs, related to '.comfy-multiline-input'
55-
if (result && result.widget
56-
&& result.widget.inputEl && result.widget.inputEl.tagName === 'TEXTAREA' && !result.widget.inputEl.readOnly) {
57-
const widgetConfig = inputData && inputData[1] ? inputData[1] : {};
58-
// Future: Add checks for Autocomplete Plus specific configurations if needed
59-
// e.g., if (widgetConfig["AutocompletePlus.enabled"] === false) return result;
60-
61-
const nodeInfo = new NodeInfo(node.comfyClass || node.constructor.name, inputName);
62-
attachListeners(result.widget.inputEl, nodeInfo);
55+
if (result && result.widget) {
56+
// fallback for older Comfyui frontend versions
57+
const inputEl = result.widget.element ?? result.widget.inputEl;
58+
if (inputEl && inputEl.tagName === 'TEXTAREA' && !inputEl.readOnly) {
59+
const widgetConfig = inputData && inputData[1] ? inputData[1] : {};
60+
// Future: Add checks for Autocomplete Plus specific configurations if needed
61+
// e.g., if (widgetConfig["AutocompletePlus.enabled"] === false) return result;
62+
63+
const nodeInfo = new NodeInfo(node.comfyClass || node.constructor.name, inputName);
64+
attachListeners(inputEl, nodeInfo);
65+
}
66+
return result;
6367
}
64-
return result;
6568
};
6669
}
6770

@@ -535,4 +538,4 @@ app.registerExtension({
535538
},
536539
},
537540
]
538-
});
541+
});

0 commit comments

Comments
 (0)