-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Autocomplete] Fix tag removal regression #36116
[Autocomplete] Fix tag removal regression #36116
Conversation
Netlify deploy previewNo updates. Bundle size report |
) { | ||
const previousHighlightedOption = previousProps.filteredOptions[highlightedIndexRef.current]; | ||
|
||
if (previousHighlightedOption) { | ||
const previousHighlightedOptionExists = filteredOptions.some((option) => { | ||
return getOptionLabel(option) === getOptionLabel(previousHighlightedOption); | ||
return isOptionEqualToValue(option, previousHighlightedOption); |
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.
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.
Ah, ok. We could use something similar to optionComparer
from Base's useListbox:
optionComparer = defaultOptionComparer, |
But then introducing yet another prop looks like an overkill. I'll leave just the bare minimum to fix the issue here, and we can discuss the approach for changing
getOptionLabel
elsewhere.
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.
Tests looks clean 👍
This PR fixes the regression introduced in #35735 and described in #36114.
It makes sure the options that are compared exist.
Before: https://codesandbox.io/s/recursing-snyder-ybg6m5?file=/demo.tsx
After: https://codesandbox.io/s/hardcore-einstein-yx1xwr?file=/demo.tsx
(see the linked issue for repro steps)
Fixes #36114.