feat: prevent form submission during IME composition in ChatInterface and ConfigDialog

This commit is contained in:
Xi Zhang
2026-06-01 01:48:38 +01:00
parent 05df6c5265
commit 53537258ba
2 changed files with 5 additions and 1 deletions
+3
View File
@@ -121,6 +121,9 @@ export const ChatInterface = React.memo<ChatInterfaceProps>(({ assistant }) => {
const handleKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
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();
+2 -1
View File
@@ -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}