From 91cf06d5fc719d53abeb31b3a181600350f27c3d Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 22 May 2026 11:11:52 +0800 Subject: [PATCH] feat(ui): auto-focus chat input when reply is clicked --- src/ui/components/chat/message-input.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ui/components/chat/message-input.tsx b/src/ui/components/chat/message-input.tsx index 27492e12..014b64cc 100644 --- a/src/ui/components/chat/message-input.tsx +++ b/src/ui/components/chat/message-input.tsx @@ -140,6 +140,20 @@ export const ChatInput = React.forwardRef( } }, [initialText]) + // Focus editor when replyingTo becomes truthy + useEffect(() => { + if (replyingTo && editorRef.current) { + editorRef.current.focus() + // Focus and move cursor to end + const range = document.createRange() + const sel = window.getSelection() + range.selectNodeContents(editorRef.current) + range.collapse(false) + sel?.removeAllRanges() + sel?.addRange(range) + } + }, [replyingTo]) + // Clean up drawing mode on unmount useEffect(() => { return () => {