From 28a00a50373c1e8f16a320833a06eb94fdcc906a Mon Sep 17 00:00:00 2001 From: bsu3338 Date: Sat, 5 Aug 2023 19:27:39 -0500 Subject: [PATCH] Update TextChat.jsx --- client/src/components/Input/TextChat.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/components/Input/TextChat.jsx b/client/src/components/Input/TextChat.jsx index 8af333e4aa..199ca1bd77 100644 --- a/client/src/components/Input/TextChat.jsx +++ b/client/src/components/Input/TextChat.jsx @@ -31,6 +31,14 @@ export default function TextChat({ isSearchView = false }) { const { conversationId, jailbreak } = conversation || {}; const { isSpeechSupported, isListening, text: speechText, toggleListening } = useSpeechRecognition(ask); + useEffect(() => { + if (isListening && speechText) { + setText(speechText); + } else { + setText(''); + } + }, [speechText, isListening, setText]); + // auto focus to input, when enter a conversation. useEffect(() => { if (!conversationId) { @@ -114,7 +122,7 @@ export default function TextChat({ isSearchView = false }) { const changeHandler = (e) => { const { value } = e.target; - setText(value || speechText); + setText(value); }; const getPlaceholderText = () => {