fix(modal): input carry over with IMEs in modal forms#2709
Conversation
🦋 Changeset detectedLatest commit: fd30f0b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@ryo-manba is attempting to deploy a commit to the NextUI Inc Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe update introduces a patch for the Changes
Assessment against linked issues
Possibly related issues
Recent Review DetailsConfiguration used: .coderabbit.yaml Files selected for processing (2)
Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
| "@nextui-org/modal": patch | ||
| --- | ||
|
|
||
| prevent IME input carryover in form fields when tabbing |
There was a problem hiding this comment.
Consider starting the description with an uppercase letter for proper grammar.
- prevent IME input carryover in form fields when tabbing
+ Prevent IME input carryover in form fields when tabbingCommittable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| prevent IME input carryover in form fields when tabbing | |
| Prevent IME input carryover in form fields when tabbing |
| const onKeyDown = useCallback((e: KeyboardEvent) => { | ||
| if (e.key === "Tab" && e.nativeEvent.isComposing) { | ||
| e.stopPropagation(); | ||
| e.preventDefault(); | ||
| } | ||
| }, []); |
There was a problem hiding this comment.
The onKeyDown callback correctly handles the Tab key during IME composition to prevent unwanted character carryover. Consider adding comments to explain the logic for future maintainability.
+ // Handle Tab key during IME composition to prevent input carryover
const onKeyDown = useCallback((e: KeyboardEvent) => {
+ // Check if the Tab key is pressed and the event is part of a composition session
if (e.key === "Tab" && e.nativeEvent.isComposing) {
+ // Stop event propagation and prevent the default action
e.stopPropagation();
e.preventDefault();
}
}, []);Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| const onKeyDown = useCallback((e: KeyboardEvent) => { | |
| if (e.key === "Tab" && e.nativeEvent.isComposing) { | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| } | |
| }, []); | |
| // Handle Tab key during IME composition to prevent input carryover | |
| const onKeyDown = useCallback((e: KeyboardEvent) => { | |
| // Check if the Tab key is pressed and the event is part of a composition session | |
| if (e.key === "Tab" && e.nativeEvent.isComposing) { | |
| // Stop event propagation and prevent the default action | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| } | |
| }, []); |
Closes #2445
📝 Description
Fixed an issue where typing with an IME (like Korean or Japanese) and pressing tab would carry the input to the next field. This was resolved using the isComposing property.
modal-form-input-with-korean-language.mov
⛳️ Current behavior (updates)
When entering text in a modal form using Korean, pressing the tab key causes the last character to be entered into the next input field.
🚀 New behavior
Pressing the tab key after entering text in Korean no longer transfers the last character to the next input field.
💣 Is this a breaking change (Yes/No):
No.
📝 Additional Information
This bug does not occur in Storybook, so the behavior was verified using the docs.
This was tested using both Japanese and 2-set Korean IMEs on browsers including Chrome, Safari, and Firefox.
Summary by CodeRabbit
ModalContentcomponent.