-
Notifications
You must be signed in to change notification settings - Fork 934
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
[useSelect]: highlightedIndex vs selectedItem #935
Comments
Unfortunately it is a bit confusing to have selectedIndex made sense only if we had multiple selection, and that item was selected along with other ones. In case of multiple selection, ARIA is ok with having https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html |
I just hit this same issue, and I'm working with a multi-select listbox. |
Hi @jrnail23 ! I probably can agree with the second part, but not sure about the first part, since you cannot have a selected item element if it's not selected. Can you provide some documentation / guideline about this? Or maybe some relevant examples? Also please feel free to create a new issue if you think we should try to improve anything. Thank you! |
@silviuaavram, the following is excerpted from WAI-ARIA Roles, States, and Properties of a listbox widget from WAI-ARIA Authoring Practices 1.1:
Also see:
The point here is that the selected options of a dropdown (those options that reflect the value(s) of the "form field"), in general, must have Currently, I have to add custom code to set |
I misunderstood, sorry. I thought you wanted I think we should improve useMultipleSelection. It should expose getItemProps which should add aria-selected on the selected item, as you requested, if that item is still in the menu and not removed. I should also work without any selected item Tags, and when navigating Left-Right it should first check if there is a Tag for selected items or not. A nice to have should be also a getSelectedItemRemoveIcon or something similar to be added to the I am thinking to start working on these and will keep this ticket for tracking. If you have additional feedback please share. Thank you! |
Just wanted to add: based on this WAI-ARIA example, I think the highlighted option should always be selected (in effect, moving the highlight by pressing up/down should automatically select the newly highlighted option): This is currently not the case in the Update: just realised this behaviour is OS-dependant. I am on macOS, and while the native |
As far as I can tell, there's only one WAI-ARIA example that
and that's the multiselect listbox, in which In all other examples, highlighting an option is equivalent to selecting it. Even in "Combobox with Listbox" example 1, where the widget doesn't visually indicate that an item has been selected on highlight, the only thing that will prevent it from being selected at that point is hitting the "clear input" button or changing the combobox value. That the highlighted option receives I think this has fueled confusion over what the correct application |
This should be fixed in v7 for useSelect. Will also fix it for useCombobox. |
Was this fixed in useCombobox? |
Once ARIA agrees on moving forward, we will implement their guidance. |
downshift
version: 4.1.0node
version: 12.13.0npm
(oryarn
) version:yarn
1.21.1This is mostly a question, What is the difference between
highlightedIndex
andselectedItem
, besides the obvious index vs item?highlightedIndex
from the naming would be the item being hovered or focused. However, it seems to mean something more akin to "selectedIndex".highlightedIndex
is used for calculatingaria-selected
which is even more confusing IMO. I'm unsure how I can tell a hover/highlighted state from an actual selected state sincearia-selected
is changed to true for any item that is hovered.I would propose renaming
highlightedIndex
toselectedIndex
and adding a newhighlightedIndex
that is the actual hover/highlighted state.I could be misunderstanding or missing how to find the actual selected item though. For now I'm working around it by adding
aria-checked={selectedItem && selectedItem === item}
.The text was updated successfully, but these errors were encountered: