Skip to content

Prevent Enter from sending during IME composition - #2

Open
57wuchi wants to merge 4 commits into
madebypan:mainfrom
57wuchi:fix/ime-enter-send
Open

Prevent Enter from sending during IME composition#2
57wuchi wants to merge 4 commits into
madebypan:mainfrom
57wuchi:fix/ime-enter-send

Conversation

@57wuchi

@57wuchi 57wuchi commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • prevent the composer from sending when Enter is used to confirm an active IME composition
  • preserve the existing Enter-to-send and Shift+Enter-to-newline behavior after composition ends
  • document the keyboard behavior in both English and Traditional Chinese

Problem

When typing Chinese or other text with an input method editor, Enter is used to confirm the underlined composition candidate. The composer currently handles that same keydown as a send action, which can submit incomplete text before the user has finished composing.

Implementation

  • track the textarea's compositionstart and compositionend lifecycle
  • return from handleKeydown while either the local composition flag or KeyboardEvent.isComposing is active
  • run the composition guard before both @mention selection and message-send handling
  • add a regression contract test for the composition lifecycle and guard ordering
  • update README.md and README.zh-TW.md with the expected keyboard behavior

Expected behavior

  1. While IME composition is underlined, Enter confirms the selected text without sending.
  2. After composition ends, the next Enter sends the message.
  3. Shift+Enter continues to insert a new line.

Testing

  • node scripts/build.js
  • node --test test/*.test.js
  • 31 tests passed

Track composition state so Enter confirms Chinese and other IME input before a later Enter sends the message.
Explain that Enter confirms active IME composition and sends only after composition ends.
說明中文輸入法組字時 Enter 只確認選字,組字結束後再次按 Enter 才送出。
Verify the composition guard runs before Enter handling and that the textarea tracks composition lifecycle events.
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