Use built-in input update event

This also solves the annoying console error after completion, which was due to missing the target property
See https://github.com/gradio-app/gradio/issues/2981 for details
This commit is contained in:
Dominik Reh
2023-02-21 18:25:17 +01:00
parent 6269c40580
commit b5817b8d4a

View File

@@ -312,9 +312,9 @@ async function insertTextAtCursor(textArea, result, tagword) {
textArea.selectionStart = afterInsertCursorPos + optionalComma.length;
textArea.selectionEnd = textArea.selectionStart
// Since we've modified a Gradio Textbox component manually, we need to simulate an `input` DOM event to ensure its
// internal Svelte data binding remains in sync.
textArea.dispatchEvent(new Event("input", { bubbles: true }));
// Since we've modified a Gradio Textbox component manually, we need to simulate an `input` DOM event to ensure it's propagated back to python.
// Uses a built-in method from the webui's ui.js which also already accounts for event target
updateInput(textArea);
// Update previous tags with the edited prompt to prevent re-searching the same term
let weightedTags = [...newPrompt.matchAll(WEIGHT_REGEX)]