-
-
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
[Select][base-ui] Removes highlighted
class on item deselection
#38790
Conversation
Netlify deploy previewhttps://deploy-preview-38790--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
@@ -217,10 +217,11 @@ function handleItemSelection<ItemValue, State extends ListState<ItemValue>>( | |||
// if the item is already selected, remove it from the selection, otherwise add it | |||
const newSelectedValues = toggleSelection(item, selectedValues, selectionMode, itemComparer); | |||
|
|||
const highlightedValue = selectedValues.includes(items[itemIndex]) ? null : item; |
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.
since itemIndex
is calculated by taking itemComparer
into consideration, i reused itemIndex
here.
highlighted
classhighlighted
class on item deselection
IMO the UX is worse now. When I use the keyboard to deselect an option, I don't want the highlight to be reset, but to stay on the option I just deselected so I can move to other options. |
Got it. What about highlighting reset only when user clicks on option? If user deselects through keyboard option will stay highlighted |
@michaldudak what do you think about current UX. I've fixed UX issue you described, additionally other issue also got fixed automatically (you can find this in PR description) |
I'm not convinced it's the right approach. Since I interacted with a given option, it makes sense to be focused (= highlighted). As for issue 2, it's a controversial topic. IMO keyboard and mouse highlights should be separate (= the current behavior). We could make it more apparent by changing the option hover style so it's different from the highlighted state. |
closes: #38789
This PR fixes 2 issues described below.
steps to reproduce
Issue 1
before:
after:
Issue 2
before:
space
buttonten
option is deselected where infact30
should be selected.(benchmark for this behaviour: https://ariakit.org/examples/select-multiple )
after:
space
button30
is selected.