Skip to content

Chat UI: Enter key sends message during CJK IME composition #429

@atoship-dev

Description

@atoship-dev

Bug Description

When using Chinese (CJK) Input Method Editor (IME) in the web chat UI, pressing Enter to confirm/select a character from the candidate list immediately sends the message instead of just confirming the character selection.

Steps to Reproduce

  1. Open the OpenFang dashboard chat (http://127.0.0.1:4200)
  2. Switch to a Chinese IME (e.g., Pinyin)
  3. Type pinyin characters (e.g., "ni hao")
  4. When the candidate list appears, press Enter to select a character
  5. Expected: The selected character is inserted into the input field
  6. Actual: The incomplete/partial text is sent as a message immediately

Expected Behavior

Pressing Enter during IME composition should only confirm the character selection. The message should only be sent when Enter is pressed after composition ends (i.e., when isComposing is false).

Suggested Fix

Add an isComposing check to the keydown event handler:

textarea.addEventListener('keydown', (e) => {
  if (e.key === 'Enter' && !e.isComposing) {
    sendMessage();
  }
});

Environment

  • OS: macOS (Apple Silicon)
  • OpenFang version: 0.3.29
  • IME: macOS built-in Chinese Pinyin

References

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