From 2e9a81dfbac29081c0c990200da8060322d823bb Mon Sep 17 00:00:00 2001 From: akhisud3195 Date: Thu, 3 Apr 2025 23:08:35 +0530 Subject: [PATCH] Fix compose box chat clearing issue --- apps/rowboat/components/common/compose-box.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/rowboat/components/common/compose-box.tsx b/apps/rowboat/components/common/compose-box.tsx index f82e78be..4ca7aecc 100644 --- a/apps/rowboat/components/common/compose-box.tsx +++ b/apps/rowboat/components/common/compose-box.tsx @@ -36,8 +36,13 @@ export function ComposeBox({ if (!prompt) { return; } + + // Clear input before calling handleUserMessage setInput(''); - + if (inputRef.current) { + inputRef.current.value = ''; + } + handleUserMessage(prompt); } @@ -49,8 +54,11 @@ export function ComposeBox({ } // focus on the input field useEffect(() => { - inputRef.current?.focus(); - }, [messages]); + if (inputRef.current) { + inputRef.current.focus(); + inputRef.current.value = input; // Ensure sync with state + } + }, [messages, input]); return (