STRING inputs changed by Javascript #15943
|
I have a custom node that changes the readonly textarea attached to a STRING widget (widget.element.value) through Javascript. In previous Comfy versions, the node worked as expected. On running of the workflow, the node's function received the value of the textarea. Now, the value received by the function isn't updating. To test, I removed the readonly attribute and manually entered text which was received by the function. There seems to be something missing between the manual input (which works) and the dynamic change via Javascript (which doesn't). Does anyone know what I need to do to make Comfy recognize the change in textarea value? |
Replies: 2 comments 1 reply
Re: STRING inputs changed by JavascriptLock the variables before assuming a logic bug:
No replies yet — a minimal repro (version + one command + first error) will get you a maintainer faster than a long essay. |
|
Update the widget itself and invoke its callback if the widget has one: const nextValue = "new text";
widget.value = nextValue;
widget.callback?.(nextValue);
node.setDirtyCanvas?.(true, true);The important line is |
widget.element.valueonly changes the textarea DOM element. It does not update the LiteGraph widget value that ComfyUI serializes into the prompt.Update the widget itself and invoke its callback if the widget has one:
The important line is
widget.value = nextValue. Current frontend extension guidance explicitly treatswidget.valueas the supported read/write surface. Writing directly towidget.element.valuebypasses that state, which explains why manual typing works while the JavaScript assignment does not.