Skip to content

fix(Composer): skip send on Enter during IME composition#212

Open
greymoth-jp wants to merge 1 commit into
alibaba:masterfrom
greymoth-jp:fix/composer-ime-composing
Open

fix(Composer): skip send on Enter during IME composition#212
greymoth-jp wants to merge 1 commit into
alibaba:masterfrom
greymoth-jp:fix/composer-ime-composing

Conversation

@greymoth-jp

Copy link
Copy Markdown

Problem

Composer sends on Enter (keyCode === 13) without checking for an active IME composition. When typing CJK text (Japanese, Chinese, Korean), the Enter that confirms a conversion candidate also fires the send, so a half-composed message gets submitted before the user is done.

Fix

Add !e.nativeEvent.isComposing to the existing guard, so Enter only sends once composition has ended. isComposing is on the native KeyboardEvent rather than the React synthetic event, hence e.nativeEvent.

Verification

Render test (testing-library + jsdom): firing keyDown with keyCode: 13, isComposing: true no longer calls onSend; with isComposing: false it still sends. Reverting the one-line guard makes the composing case send again.

The Composer Enter handler called send() on keyCode 13 without checking
whether an IME composition was active. While composing CJK text
(Japanese, Chinese, Korean), the Enter that confirms a conversion
candidate also triggered send, so a half-composed message was submitted
before the user finished typing.

Guard the send with !e.nativeEvent.isComposing so Enter only sends once
composition has ended. isComposing is on the native KeyboardEvent rather
than the React synthetic event.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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