From b0372ea83b2a72e8d685d2619e661f9849cb05ee Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 14 Dec 2022 22:54:12 +0800 Subject: [PATCH] Dispatch oninput manually when textarea value change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I thought… React/Preact should do this automagically… --- src/components/compose.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 1b1ba916..0d2f5332 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -112,6 +112,7 @@ function Compose({ expiresIn: poll?.expiresIn || expiresInFromExpiresAt(poll.expiresAt), }; textareaRef.current.value = status; + textareaRef.current.dispatchEvent(new Event('input')); spoilerTextRef.current.value = spoilerText; setVisibility(visibility); setSensitive(sensitive); @@ -131,6 +132,7 @@ function Compose({ console.log({ statusSource }); const { text, spoilerText } = statusSource; textareaRef.current.value = text; + textareaRef.current.dispatchEvent(new Event('input')); textareaRef.current.dataset.source = text; spoilerTextRef.current.value = spoilerText; setVisibility(visibility);