Skip to content

fix: prevent Enter from submitting during IME composition#33

Closed
UnsongK wants to merge 1 commit intolsdefine:mainfrom
UnsongK:fix/ime-composition
Closed

fix: prevent Enter from submitting during IME composition#33
UnsongK wants to merge 1 commit intolsdefine:mainfrom
UnsongK:fix/ime-composition

Conversation

@UnsongK
Copy link

@UnsongK UnsongK commented Mar 15, 2026

Fix IME composition issue with Enter key.
When using CJK input methods(Chinese/Japanese/Korean), pressing Enter to confirm character selection was incorrectly triggering form submission.
This fix listens for compositionstart/compositionend events and blocks Enter keydown during active IME composition.

When using CJK input methods, pressing Enter to confirm character
selection was incorrectly triggering form submission. This fix listens
for compositionstart/compositionend events and blocks Enter keydown
during active IME composition.
Copy link
Owner

@lsdefine lsdefine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Two changes needed:

  1. Add OS guard: This IME issue only affects macOS — on Windows the browser correctly fires keydown after compositionend, so Enter never accidentally submits during composition. Please wrap the entire block with if os.name != 'nt': so Windows users don't get an unnecessary hidden iframe (which components.html(height=0) can still render as a visible empty element).

  2. Compress the line count: Currently +32 lines for a non-core fix is too much — it shouldn't exceed the surrounding core logic in length. The JS and Python can be significantly condensed. Please tighten it up.

@lsdefine lsdefine closed this in 3e6be97 Mar 16, 2026
@lsdefine
Copy link
Owner

Thanks for the contribution! I've incorporated the IME fix into main with a few changes:

  • Compressed the JS to a single line
  • Added if os.name != 'nt': guard so Windows users are completely unaffected
  • Removed the height parameter

Closing this PR. Appreciate the effort! 🙏

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.

2 participants