-
Notifications
You must be signed in to change notification settings - Fork 6
fix: allow form submission with single Enter press in ComboBox #884
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
Conversation
🦋 Changeset detectedLatest commit: c9e3b28 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 GitHub.
|
📦 NPM canary releaseDeployed canary version 0.0.0-canary-dfdfca0. |
🏋️ Size limit report
Click here if you want to find out what is changed in this build |
🧪 Storybook is successfully deployed!
|
| e.preventDefault(); | ||
| } | ||
| } else { | ||
| e.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Popover: Enter Submits Form Without Focus.
When the popover is open with matching results but no item is focused, pressing Enter doesn't prevent default, causing premature form submission. The Enter handler falls through all conditions without calling e.preventDefault() when hasResults is true, the input is non-empty, and no item is focused in the list.
| // If popover is open OR value is empty, prevent default to avoid premature submission | ||
| if (isPopoverOpen || !value) { | ||
| e.preventDefault(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Normalize empty custom input to null.
When allowsCustomValue is true and the user enters only whitespace then presses Enter, onSelectionChange is called with an empty string instead of null. The ?? operator on line 613 doesn't convert empty strings to null (only null/undefined), so onSelectionChange("") is called. This is inconsistent with how empty values are handled elsewhere in the component (e.g., lines 631-634), where null is used to represent "no selection". The code should check if the trimmed value is empty and call onSelectionChange(null) instead.
Note
Enables single-Enter form submission in
ComboBoxwhenallowsCustomValueand no matches, adds tests, and surfaces library version viaVERSIONanddata-tasty.aria-expandedlogic unaffected.allowsCustomValueand no matches (src/components/fields/ComboBox/ComboBox.test.tsx).VERSIONconstant insrc/version.tsand attach to root viadata-tastyinsrc/components/Root.tsx; ensurewindow.CubeUIKit.versionis defined and check for multiple versions.@cube-dev/ui-kitdescribing the ComboBox Enter submission fix.Written by Cursor Bugbot for commit c9e3b28. This will update automatically on new commits. Configure here.