From e223804777179064936137efe8f15477b1edf278 Mon Sep 17 00:00:00 2001 From: Nicolas Varrot Date: Mon, 9 Mar 2026 21:01:33 +0000 Subject: [PATCH] fix: prevent Enter from sending message during IME composition Check e.nativeEvent.isComposing and keyCode 229 in addition to React state, fixing a race condition where compositionend fires before keydown on some browsers (Chrome/macOS). Fixes #20 --- src/components/ChatInput.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ChatInput.tsx b/src/components/ChatInput.tsx index 0ccd142..9a5b1ac 100644 --- a/src/components/ChatInput.tsx +++ b/src/components/ChatInput.tsx @@ -209,7 +209,9 @@ export function ChatInput({ onSend, onNewSession, onAbort, isGenerating, disable const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { // Prevent sending when IME is composing (e.g., Chinese/Japanese input) - if (isComposing) return; + // Check both React state and native event property — on some browsers + // compositionend fires before keydown, making isComposing stale + if (isComposing || e.nativeEvent.isComposing || e.keyCode === 229) return; if (sendOnEnter) { // Enter sends, Shift+Enter for newline if (!e.shiftKey && !e.ctrlKey && !e.metaKey) {