From 9e7530d60b3b8e3a57d94ebe3de9940d6327e49b Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Wed, 11 Nov 2026 09:51:05 +0000 Subject: [PATCH] fix(chat): refocus the message box after sending Sending disabled the editor, which dropped focus, and clicking Send moved it to the button, so every message needed a click before typing the next one. Refocus the editor once the send settles. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- src/lib/components/chat/MessageInput.jsx | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c5c60b52..a59a12a2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qryptchat-web", "private": true, - "version": "0.21.1", + "version": "0.21.2", "type": "module", "bin": { "qc": "./bin/qc.js", diff --git a/src/lib/components/chat/MessageInput.jsx b/src/lib/components/chat/MessageInput.jsx index 656c7ad5..d2f92884 100644 --- a/src/lib/components/chat/MessageInput.jsx +++ b/src/lib/components/chat/MessageInput.jsx @@ -56,6 +56,10 @@ export default function MessageInput({ conversationId, disabled = false }) { const editorRef = useRef(null); const fileInputRef = useRef(null); const typingTimeoutRef = useRef(null); + // Sending disables the editor, which drops focus (and a Send click moves it + // to the button). Put the caret back once the send settles so the next + // message can be typed straight away. + const refocusAfterSend = useRef(false); const user = useAuthStore((s) => s.user); const { conversations, messages, sendMessage, setTyping, stopTyping, loadMessages, replyingTo, clearReplyingTo } = useChatStore( @@ -334,6 +338,7 @@ export default function MessageInput({ conversationId, disabled = false }) { const hasFiles = selectedFiles.length > 0; if (!hasText && !hasFiles) return; + refocusAfterSend.current = true; setIsSending(true); setIsUploadingFiles(hasFiles); setUploadError(''); @@ -387,6 +392,12 @@ export default function MessageInput({ conversationId, disabled = false }) { } } + useEffect(() => { + if (isSending || !refocusAfterSend.current) return; + refocusAfterSend.current = false; + editorRef.current?.focus(); + }, [isSending]); + const canSend = !disabled && !isSending && !isUploadingFiles && (messageText.trim() || selectedFiles.length > 0); return (