Skip to content

AI Chat submits on Enter key during IME composition (Japanese/Chinese/Korean input) #3941

@MH4GF

Description

@MH4GF

Bug description

When using the AI Assistant chat input, pressing Enter to confirm IME (Input Method Editor) composition triggers form submission instead of confirming the character conversion. This affects users typing in Japanese, Chinese, Korean, and other languages that use IME for text input.

Affected: This issue occurs on the official GitBook documentation site (https://gitbook.com/docs) as well.

Expected behavior: Enter key during IME composition should only confirm the character conversion, not submit the message.

Actual behavior: Enter key submits the partially composed text immediately.

How to reproduce

  1. Open https://gitbook.com/docs (or any GitBook site with AI Assistant enabled)
  2. Open the AI Chat panel
  3. Start typing in Japanese (or other IME-based language)
  4. While characters are being composed (underlined), press Enter to confirm the conversion
  5. The incomplete/partial text is submitted instead of confirming the IME conversion

Additional context

Root cause identified:

The Input component at packages/gitbook/src/components/primitives/Input.tsx:180 does not check for isComposing state:

// Current code
if (event.key === 'Enter' && !event.shiftKey && hasValue) {
    event.preventDefault();
    handleSubmit();
}

Proposed fix:

// Fixed code
if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing && hasValue) {
    event.preventDefault();
    handleSubmit();
}

This is a one-line change that would benefit all users who use IME-based input methods.

I'm happy to submit a PR for this fix if the approach is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions