-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
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
- Open https://gitbook.com/docs (or any GitBook site with AI Assistant enabled)
- Open the AI Chat panel
- Start typing in Japanese (or other IME-based language)
- While characters are being composed (underlined), press Enter to confirm the conversion
- 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.