From 6bb01119d0ca150e19d0fef894a15729efe6c7d7 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Wed, 8 Apr 2026 21:21:09 +0800 Subject: [PATCH] fix(web): chat input add composition --- web/src/components/Chat/ChatInput.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/components/Chat/ChatInput.tsx b/web/src/components/Chat/ChatInput.tsx index 046d133d..4843b198 100644 --- a/web/src/components/Chat/ChatInput.tsx +++ b/web/src/components/Chat/ChatInput.tsx @@ -27,6 +27,7 @@ const ChatInput: FC = ({ }) => { const [inputValue, setInputValue] = useState('') const [isFocus, setIsFocus] = useState(false) + const [isComposing, setIsComposing] = useState(false) // Clear input when external message is cleared useEffect(() => { @@ -78,9 +79,11 @@ const ChatInput: FC = ({ setInputValue(e.target.value) onChange?.(e.target.value) }} + onCompositionStart={() => setIsComposing(true)} + onCompositionEnd={() => setIsComposing(false)} onKeyDown={(e) => { // Enter to send, Shift+Enter for new line - if (e.key === 'Enter' && !e.shiftKey && (e.target as HTMLTextAreaElement).value?.trim() !== '' && !loading) { + if (e.key === 'Enter' && !e.shiftKey && !isComposing && (e.target as HTMLTextAreaElement).value?.trim() !== '' && !loading) { e.preventDefault(); handleSend(); }