Skip to content

Conversation

Decayo
Copy link

@Decayo Decayo commented Aug 14, 2025

Summary

Fix: prevent Enter submit while IME composing (CJK)

Problem

  • When composing text with a CJK IME (e.g., Chinese Zhuyin on macOS), pressing Enter should finalize composition, not submit the prompt.
  • In the compact input bar, Enter could prematurely submit while composition was still active.

Changes

  • Add explicit IME composition guards in FloatingPromptInput:
    • Track composition state via onCompositionStart / onCompositionEnd.
    • Gate Enter handling with nativeEvent.isComposing and a fallback keyCode === 229 check for environments that report 229 during composition.
  • File touched: src/components/FloatingPromptInput.tsx
  • No backend or dependency changes.

Behavior (after)

  • Enter during composition: does not submit (finalizes IME composition).
  • Enter after composition ends: submits as before.
  • Shift+Enter: inserts newline (unchanged).
  • Works in both compact and expanded input modes.

Risk / Scope

  • Scope limited to frontend input handling in FloatingPromptInput.
  • Low risk: no API, state shape, or dependency changes; only affects Enter handling when IME is active.

Test Plan

  • macOS + Chinese Zhuyin IME (also applicable to other CJK IMEs):
    1. Start composing (type phonetics), press Enter → finalizes composition, does not send.
    2. After composition completes, press Enter → sends prompt.
    3. Press Shift+Enter → inserts newline.
  • Verified in both compact and expanded input UIs.

Notes

  • This is a common IME UX issue; the fix follows widely adopted patterns used in chat/input components.
  • Maintainers can safely tweak the guard if future platforms expose better composition signals.

Checklist

  • Title follows guideline prefix (Fix:)
  • Change is minimal and isolated to the input component
  • No new dependencies
  • Manually tested locally with IME
  • Unit/UI tests (N/A for this small input behavior change)

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