Skip to content

Conversation

servak
Copy link
Owner

@servak servak commented Oct 7, 2025

Summary

Fixes a bug where Japanese (and other IME-based) input would incorrectly send messages when pressing Enter during text conversion.

Problem

After PR Chainlit#2393 rewrote the chat input to use <textarea>, the AutoResizeTextarea component was not propagating onCompositionStart and onCompositionEnd events to its parent component (Input.tsx). This caused the parent's isComposing state to always remain false, resulting in Enter key presses during IME text conversion being incorrectly interpreted as message send commands.

Solution

  • Added onCompositionStart and onCompositionEnd to AutoResizeTextarea component props
  • Created handler functions that:
    1. Update the component's internal isComposing state
    2. Propagate the events to parent handlers if provided
  • This ensures both the AutoResizeTextarea and parent components correctly track IME composition state

Test Plan

Tested with Japanese IME input:

  1. ✅ Type "english" and press Enter → message sends correctly
  2. ✅ Type "こんにちは" (Japanese) and press Enter during conversion → text is confirmed, message does NOT send
  3. ✅ After confirming Japanese text, press Enter → message sends correctly

Related Issues

This bug was introduced in PR Chainlit#2393 when migrating from contentEditable to <textarea>.

AutoResizeTextarea was not propagating onCompositionStart and
onCompositionEnd events to its parent component, causing the parent's
isComposing state to remain false during IME input (Japanese, Chinese,
Korean, etc.). This resulted in Enter key presses during text conversion
being incorrectly interpreted as message send commands.

This fix adds proper event propagation by:
- Adding onCompositionStart and onCompositionEnd to component props
- Creating handler functions that update internal state and call parent handlers
- Ensuring both local and parent components track IME composition state correctly

Fixes the issue where Japanese input would send messages on Enter during conversion.
@servak servak closed this Oct 7, 2025
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.

1 participant