Skip to content

Conversation

smorimoto
Copy link
Contributor

@smorimoto smorimoto commented Oct 15, 2025

Summary

Fixes form submission during IME composition in PromptInputTextarea.

Problem

When users type in Japanese (or other languages requiring IME), pressing Enter to confirm character conversion would incorrectly submit the form instead of just completing the conversion. This made the input field difficult to use for CJK language users.

Solution

Added explicit composition state tracking using:

  • onCompositionStart: Sets isComposing to true
  • onCompositionEnd: Sets isComposing to false
  • Enhanced handleKeyDown to check both the local isComposing state and
    e.nativeEvent.isComposing

This ensures the Enter key during composition is handled by the IME, not the form submission logic.

Testing

  • Manually tested with Japanese IME input

Related

Add composition event handlers to PromptInputTextarea to prevent
premature form submission when users press Enter to confirm IME input
(e.g., Japanese, Chinese, Korean). The component now tracks composition
state explicitly using onCompositionStart and onCompositionEnd events,
in addition to checking the native isComposing property.

This fixes an issue where Japanese users typing with an IME would
accidentally submit the form when pressing Enter to convert kanji,
instead of just confirming the conversion.

Signed-off-by: Sora Morimoto <sora@morimoto.io>
Copy link

vercel bot commented Oct 15, 2025

@smorimoto is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@haydenbleasel
Copy link
Collaborator

Nice one, thanks @smorimoto 🙏

@haydenbleasel haydenbleasel merged commit fda2d1c into vercel:main Oct 15, 2025
2 of 5 checks passed
@smorimoto smorimoto deleted the fix/ime-composition-enter-key branch October 16, 2025 01:03
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