Skip to content

fix(UI): prevent search triggering on IME composition Enter key press#1029

Open
ryo9999 wants to merge 2 commits intoItzCrazyKns:masterfrom
ryo9999:master
Open

fix(UI): prevent search triggering on IME composition Enter key press#1029
ryo9999 wants to merge 2 commits intoItzCrazyKns:masterfrom
ryo9999:master

Conversation

@ryo9999
Copy link

@ryo9999 ryo9999 commented Mar 6, 2026

Description

Currently, when a user typing in a language that uses an Input Method Editor (IME) — such as Japanese, Chinese, or Korean — presses the Enter key to confirm their text composition, it inadvertently triggers the sendMessage function. 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.isComposing check to the onKeyDown handlers in both EmptyChatMessageInput.tsx and MessageInput.tsx.

Changes

  • src/components/EmptyChatMessageInput.tsx: Added !e.nativeEvent.isComposing condition to the Enter key check.
  • src/components/MessageInput.tsx: Added !e.nativeEvent.isComposing condition to the Enter key check.

Testing

  • Verified that pressing Enter to confirm IME text conversion does not trigger the search submission.
  • Verified that pressing Enter continuously after the IME text conversion is finalized correctly triggers the search submission as intended.
  • Verified that standard English input with Enter still 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.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-ai with guidance or docs links (including llms.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.

@ryo9999
Copy link
Author

ryo9999 commented Mar 6, 2026

Added support for Safari.
Fixed an issue in Safari where the search would unintentionally trigger while confirming IME text (e.g., Japanese).
Because Safari's compositionend is sometimes immediately followed by an Enter keydown event without isComposing being reliably true, the fix now binds the composition events and keydown listener directly to the Textarea component. It also incorporates a 150ms delay check after compositionend and ignores keyCode === 229 to ensure cross-browser IME stability. Tested and verified working on Chrome and Safari.

Copy link

@xkonjin xkonjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants