From 53537258bad312b636d8d0efc0a795eb306b779e Mon Sep 17 00:00:00 2001 From: Xi Zhang Date: Mon, 1 Jun 2026 01:48:38 +0100 Subject: [PATCH] feat: prevent form submission during IME composition in ChatInterface and ConfigDialog --- src/app/components/ChatInterface.tsx | 3 +++ src/app/components/ConfigDialog.tsx | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/components/ChatInterface.tsx b/src/app/components/ChatInterface.tsx index 45fb669..32d78ab 100644 --- a/src/app/components/ChatInterface.tsx +++ b/src/app/components/ChatInterface.tsx @@ -121,6 +121,9 @@ export const ChatInterface = React.memo(({ assistant }) => { const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (submitDisabled) return; + // Don't submit while an IME is composing (e.g. pressing Enter to pick a + // Chinese/Japanese/Korean candidate must confirm text, not send). + if (e.nativeEvent.isComposing || e.keyCode === 229) return; if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSubmit(); diff --git a/src/app/components/ConfigDialog.tsx b/src/app/components/ConfigDialog.tsx index 41880cc..dbc4d89 100644 --- a/src/app/components/ConfigDialog.tsx +++ b/src/app/components/ConfigDialog.tsx @@ -96,7 +96,8 @@ export function ConfigDialog({ if (error) setError(null); }} onKeyDown={(e) => { - if (e.key === "Enter") handleSave(); + if (e.key === "Enter" && !e.nativeEvent.isComposing) + handleSave(); }} aria-invalid={error ? true : undefined} aria-describedby={error ? "deploymentUrl-error" : undefined}