Repository navigation
Conversation
Deploy previewBundle size
PerformanceNo regressions in 32 benchmarks · precise to ±8.3% (±16.8% at worst) · ran 4m 01s · details Check out the code infra dashboard for more information about this PR. |
This branch has not been deployed
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.
Closes #49863
When
optionschange while the listbox is open,useAutocompletere-finds the previously highlighted option by its label, andsyncHighlightedIndexis memoised onfilteredOptions.length. So:getOptionKey, a same-length reorder leaves the highlight on the old index: the right row looks highlighted, but Enter selects the other option;isOptionEqualToValue, a refetch that changes the highlighted option's label drops the highlight.This PR keeps a highlight the user set (keyboard, mouse or touch) on the same option at its new index. "Same option" is decided in this order:
getOptionKey, when it is provided;isOptionEqualToValueorgetOptionValueis passed, the existingisOptionEqualToValue(option, getOptionValue(other))fromuseOptionValue;Unchanged behaviour:
autoHighlightstill moves to the new first option ([autocomplete] Fix auto highlight when options change but not the length #46489).optionsprop changes, so the callback call-count guarantees while typing hold.Implementation notes:
syncHighlightedIndexkeeps its dependency list, so it still runs at the same times; its body now reads the latest render throughuseEventCallback.optionsarray arrives, so a remounted row (a label-keyed<li>) gets the focused class back.getOptionKey,isOptionEqualToValueandgetOptionValuedocuments the rule. PropTypes and the API docs are regenerated.Tests added under
highlight synchronisation: duplicate labels withgetOptionKey, a label change withisOptionEqualToValue(including two refetches in a row),getOptionValue, a user highlight withautoHighlight, a mouse highlight,disableCloseOnSelect, and the reset when the option is removed. Six of the seven fail on master; the reset test passes on master and guards existing behaviour.