From b5817b8d4af4a764ca92c0067a3f6e10398464bd Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Tue, 21 Feb 2023 18:25:17 +0100 Subject: [PATCH] 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 --- javascript/tagAutocomplete.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 9f93b57..82f02b3 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -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)]