Finish the Dropdown selection the keyboard started - #311
Merged
Merged
Conversation
A filtered Dropdown narrowed correctly and made an option keyboard-active with ArrowDown, but Enter left the filter text unchanged, the listbox mounted and aria-expanded true. The value was reported through onChange; nothing else about the commit happened. React Aria treats a filtered single selection as finished only when the key the ComboBox was handed changes, and deliberately stands down otherwise so the application can drive the closing. That key was derived from the `value` prop alone, so an application that does not feed the emitted value straight back - or that answers with a value none of the options carry - never got the overlay closed or the filter text settled, and had no handle on either: the Dropdown exposes no open state and no input value. The Dropdown now remembers the option the user committed, so the commit completes on its own, and closes the filtered overlay itself instead of waiting for a value that may never resolve. An incoming `value` still decides what is selected and still drops the remembered option the moment the consumer answers, so a round-tripping application renders exactly as before. The same memory gives the unfiltered trigger its selected label instead of leaving the placeholder standing. Covered by jsdom specs for ArrowDown, ArrowUp, Escape and the unfiltered path across both bindings, and by a browser story that types, arrows and commits with no value bound at all. (#239)
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.
Summary
A filtered
Dropdowncould narrow to the option you wanted and make it keyboard-active with ArrowDown, but Enter did not finish the job: the filter text stayed as typed, the list stayed open, andaria-expandedstayedtrue. The value was reported, but the selection never landed. Keyboard-only users could not pick an option at all.Closing the list and settling the filter text was left to the value the application sends back in. An application that does not feed the emitted value straight back, or that answers with a value none of the options carry, never got either — and had no way to do it itself, because the Dropdown exposes neither open state nor input value. The Dropdown now completes the selection it started.
No CSS changed and no markup changed. An application that already feeds the value straight back renders identical DOM before and after. Where the value is not fed back, the Dropdown now renders the selection it committed — filter text, trigger label,
data-selected, and the clear action whenshowClearis set — instead of the stale filter text it used to leave behind. That is the fix, and it is a visible difference for anyone who was living with the defect.Fixed
Dropdownnow commits the option ArrowDown or ArrowUp made active: Enter reports it once, closes the list, and shows its label. Escape still dismisses without changing the selection (Filtered Dropdown does not commit the active option with ArrowDown and Enter #239)Dropdownselection now closes its own overlay and settles its own filter text, instead of waiting for avaluethat may never come back or may resolve to none of the options (Filtered Dropdown does not commit the active option with ArrowDown and Enter #239)Dropdownnow shows the label of the option that was chosen, rather than keeping its placeholder, when the application does not bind the value back (Filtered Dropdown does not commit the active option with ArrowDown and Enter #239)