[combobox] Clear value on Escape from Trigger in input-inside-popup#4946
Draft
spokodev wants to merge 1 commit into
Draft
[combobox] Clear value on Escape from Trigger in input-inside-popup#4946spokodev wants to merge 1 commit into
spokodev wants to merge 1 commit into
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,122.83 ms +24.80 ms(+2.3%) | Renders: 50 (+0) | Paint: 1,687.75 ms +17.78 ms(+1.1%)
10 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4938.
In the input-inside-popup pattern (
<Combobox.Trigger>outside,<Combobox.Input>inside<Combobox.Popup>),Combobox.Triggerwas the keyboard entry point when the popup was closed, but it had no handler forEscape. So users could not clear a selected value without first opening the popup, focusing the Input, and pressingEscapethere. The issue author posted a manual workaround that simulated a click onCombobox.Clear.This adds an
Escapebranch toCombobox.Trigger'sonKeyDownthat mirrors the existing clear path inComboboxInput.tsx(around line 399): it only fires wheninputInsidePopupis true and the popup is not mounted, callssetSelectedValuewithnull(single) or[](multiple), and stops propagation only when there was something to clear, not inline, and propagation was not explicitly allowed.disabledandreadOnlyare respected via the early return at the top of the handler.Combobox.Inputin the outside-popup pattern keeps its existing behavior. The Trigger handler only activates when the popup is closed, so when the popup is open the Escape goes through the Input as before.11 new tests in
ComboboxTrigger.test.tsxcover:null, multi to[])disabled,Combobox.Root disabled,Combobox.Root readOnly, controlled value flow,details.reason === REASONS.escapeKey)All four fail on master and pass on this branch.
Verification
Open as draft until CI confirms.