feat(ui): auto-focus chat input when reply is clicked

This commit is contained in:
yiling
2026-05-22 11:11:52 +08:00
parent 206e1ae7b1
commit 91cf06d5fc
+14
View File
@@ -140,6 +140,20 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
}
}, [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 () => {