From 7ef1f3e2f880b98d0bca62b59c9b2d1690b830af Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sat, 7 Feb 2026 15:30:07 +0530 Subject: [PATCH] feat(chat): improve focus management for chat input after sending messages --- frontend/src/components/BoardChatComposer.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/BoardChatComposer.tsx b/frontend/src/components/BoardChatComposer.tsx index f2884402..68a07a06 100644 --- a/frontend/src/components/BoardChatComposer.tsx +++ b/frontend/src/components/BoardChatComposer.tsx @@ -1,6 +1,6 @@ "use client"; -import { memo, useCallback, useState } from "react"; +import { memo, useCallback, useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; @@ -17,12 +17,22 @@ function BoardChatComposerImpl({ onSend, }: BoardChatComposerProps) { const [value, setValue] = useState(""); + const textareaRef = useRef(null); + const shouldFocusAfterSendRef = useRef(false); + + useEffect(() => { + if (isSending) return; + if (!shouldFocusAfterSendRef.current) return; + shouldFocusAfterSendRef.current = false; + textareaRef.current?.focus(); + }, [isSending]); const send = useCallback(async () => { if (isSending) return; const trimmed = value.trim(); if (!trimmed) return; const ok = await onSend(trimmed); + shouldFocusAfterSendRef.current = true; if (ok) { setValue(""); } @@ -31,6 +41,7 @@ function BoardChatComposerImpl({ return (