Skip to content

fix: ignore Enter during IME composition#53

Open
greymoth-jp wants to merge 1 commit into
mrdjohnson:mainfrom
greymoth-jp:fix/ime-composition-enter
Open

fix: ignore Enter during IME composition#53
greymoth-jp wants to merge 1 commit into
mrdjohnson:mainfrom
greymoth-jp:fix/ime-composition-enter

Conversation

@greymoth-jp

Copy link
Copy Markdown

Typing Japanese, Chinese or Korean goes through an IME, where the first Enter confirms the current composition candidate rather than submitting. The keydown handler in ChatBoxInputRow only checked e.key === 'Enter' && messageContent, so that confirming Enter sent the message on a half-finished word.

I added !e.nativeEvent.isComposing to the send condition. nativeEvent is the underlying DOM KeyboardEvent, which exposes isComposing; React's synthetic event type doesn't surface it directly, so reading it off nativeEvent keeps it type-safe.

Repro: set the OS to a Japanese IME, type something like かんじ in the prompt box and press Enter to pick a kanji candidate.

  • Before: the message sends on the unfinished text.
  • After: that Enter only confirms the candidate; a plain Enter still sends as usual.

Pressing Enter to confirm an IME candidate (Japanese/Chinese/Korean input)
sent the message early because the keydown handler did not check whether a
composition was in progress. Add a !e.nativeEvent.isComposing guard so Enter
only sends once composition has ended.
@mrdjohnson mrdjohnson self-assigned this Jun 30, 2026

@mrdjohnson mrdjohnson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

TIL! Thank you for this

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