fix(UI): prevent search triggering on IME composition Enter key press#1029
fix(UI): prevent search triggering on IME composition Enter key press#1029ryo9999 wants to merge 2 commits intoItzCrazyKns:masterfrom
Conversation
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/MessageInput.tsx">
<violation number="1" location="src/components/MessageInput.tsx:57">
P2: IME guard may be incomplete in Safari because `isComposing` can be false when Enter keydown fires (compositionEnd fires before keydown in Safari). Consider using a ref-based composition state with compositionStart/End event handlers for cross-browser compatibility.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
… (Safari compatible)
|
Added support for Safari. |
xkonjin
left a comment
There was a problem hiding this comment.
Quick review pass:
- Main risk area here is UI state transitions, empty/error states, and interaction regressions.
- I didn’t see targeted regression coverage in the diff; please add or point CI at a focused test for the changed path in EmptyChatMessageInput.tsx, MessageInput.tsx.
- Before merge, I’d smoke-test the behavior touched by EmptyChatMessageInput.tsx, MessageInput.tsx with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.
Description
Currently, when a user typing in a language that uses an Input Method Editor (IME) — such as Japanese, Chinese, or Korean — presses the
Enterkey to confirm their text composition, it inadvertently triggers thesendMessagefunction. This results in the search being submitted prematurely before the user has finished typing their query.This PR fixes this issue by adding a
!e.nativeEvent.isComposingcheck to theonKeyDownhandlers in both EmptyChatMessageInput.tsx and MessageInput.tsx.Changes
!e.nativeEvent.isComposingcondition to theEnterkey check.!e.nativeEvent.isComposingcondition to theEnterkey check.Testing
Enterto confirm IME text conversion does not trigger the search submission.Entercontinuously after the IME text conversion is finalized correctly triggers the search submission as intended.Enterstill works correctly.Summary by cubic
Prevent Enter from submitting during IME composition in EmptyChatMessageInput and MessageInput, so Japanese/Chinese/Korean input doesn’t send queries early. Added composition tracking and Safari-safe handling (ignore keyCode 229 and wait 150ms after composition end); Enter then submits, and Shift+Enter still inserts a newline.
Written for commit f16de62. Summary will update on new commits.