From d4f03f743a7e0009448d7a2c2962bc7e2aa12d76 Mon Sep 17 00:00:00 2001 From: tantanorange Date: Sun, 11 Jan 2026 18:13:05 -0800 Subject: [PATCH] bug(issue-784): fixed 'Enter' trigger unexpected Chat under Iput Method Editor. --- src/apps/chat/components/composer/Composer.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/apps/chat/components/composer/Composer.tsx b/src/apps/chat/components/composer/Composer.tsx index 7e540e132..6fed08d17 100644 --- a/src/apps/chat/components/composer/Composer.tsx +++ b/src/apps/chat/components/composer/Composer.tsx @@ -125,6 +125,7 @@ export function Composer(props: { const [micContinuation, setMicContinuation] = React.useState(false); const [speechInterimResult, setSpeechInterimResult] = React.useState(null); const [sendStarted, setSendStarted] = React.useState(false); + const [isComposing, setIsComposing] = React.useState(false); const { chatExecuteMode, chatExecuteModeSendColor, chatExecuteModeSendLabel, @@ -538,6 +539,14 @@ export function Composer(props: { isMobile && actileInterceptTextChange(e.target.value); }, [actileInterceptTextChange, isMobile, setComposeText]); + const handleCompositionStart = React.useCallback(() => { + setIsComposing(true); + }, []); + + const handleCompositionEnd = React.useCallback(() => { + setIsComposing(false); + }, []); + const handleTextareaKeyDown = React.useCallback(async (e: React.KeyboardEvent) => { // disable keyboard handling if the actile is visible if (actileInterceptKeydown(e)) @@ -545,6 +554,9 @@ export function Composer(props: { // Enter: primary action if (e.key === 'Enter') { + if (isComposing) { + return; + } // Alt (Windows) or Option (Mac) + Enter: append the message instead of sending it if (e.altKey && !e.metaKey && !e.ctrlKey) { @@ -572,7 +584,7 @@ export function Composer(props: { } } - }, [actileInterceptKeydown, assistantAbortible, chatExecuteMode, composeText, enterIsNewline, handleSendAction, touchAltEnter, touchCtrlEnter, touchShiftEnter]); + }, [actileInterceptKeydown, assistantAbortible, chatExecuteMode, composeText, enterIsNewline, handleSendAction, isComposing, touchAltEnter, touchCtrlEnter, touchShiftEnter]); // Focus mode @@ -866,6 +878,8 @@ export function Composer(props: { value={composeText} onChange={handleTextareaTextChange} onKeyDown={handleTextareaKeyDown} + onCompositionStart={handleCompositionStart} + onCompositionEnd={handleCompositionEnd} onPasteCapture={handleAttachCtrlV} // onFocusCapture={handleFocusModeOn} // onBlurCapture={handleFocusModeOff}