Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle IME composition to prevent unintended submissions (#785) #786

Closed
wants to merge 1 commit into from

Conversation

cgoinglove
Copy link

Summary:

This PR fixes the IME composition error (#785) that causes the chat input field to retain the last word when submitting messages using an IME for languages such as Chinese, Korean, and Japanese. The error occurs because the Enter key event is processed while text composition is still in progress.

Issue Details:

When using an IME (for example, for Chinese, Korean, or Japanese input), text composition occurs in stages. The original submission condition was:

if (event.key === 'Enter' && !event.shiftKey)

This condition did not account for active text composition. As a result, pressing Enter during composition immediately processes the event, leaving the final composed word in the input field.

Fix:

The submission condition has been updated to include a check for ongoing text composition. The new condition is

if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing)

This fix specifically addresses the IME composition error, and it should improve the behavior for other languages that rely on similar input methods.

Copy link

vercel bot commented Feb 12, 2025

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

A member of the Team first needs to authorize it.

@Rajaniraiyn
Copy link

implemented from cec3784

@cgoinglove cgoinglove closed this Mar 14, 2025
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