Skip to content

fix(web): Chinese IME Enter sends message instead of confirming composition #247

@zhangweijian97

Description

@zhangweijian97

Bug Description

When using Chinese IME (or other CJK input methods) in the chat input, pressing Enter to confirm/select the composed characters instead triggers message submission.

Steps to Reproduce

  1. Open the Web UI chat
  2. Activate Chinese IME (e.g., Pinyin, Wubi)
  3. Type pinyin characters (e.g., "ni hao")
  4. Press Enter to confirm the Chinese characters
  5. Instead of confirming the input, the message is sent immediately

Root Cause

In packages/web/src/components/chat-room/chat-composer.tsx, the handleKeyDown function checks for Enter key but does not account for IME composition state:

if (event.key === "Enter" && !event.shiftKey) {
    event.preventDefault();
    onSubmit();
}

There is no check for event.nativeEvent.isComposing. During IME composition, Enter is used to confirm/select characters, not to submit the message.

Expected Behavior

Pressing Enter during IME composition should confirm the input, not send the message. Only press Enter when isComposing === false should trigger submission.

Fix

Add a guard for the composition state:

if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
    event.preventDefault();
    onSubmit();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions