-
Notifications
You must be signed in to change notification settings - Fork 125
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
Authors do not need to set aria-selected in single-selection containers… #1327
Conversation
…here selection follows focus
One case that comes up is a single selection container where the author wants to convey that nothing is selected, not even the focused item. In this case, the browsers that I know of will make use of aria-selected="false" on the focused item, and should result in the screen reader conveying that the item is not selected. |
Wow, that's a wild case that should be spec'd explicitly, because I wouldn't have guessed that one. How about:
Would that work? |
I understand the intent but as far as I know there is no negative consequence to an author setting aria-selected on the focused node - they are just doing extra unnecessary work. Why would we make this a SHOULD NOT? |
The intent is to clarify. SHOULD NOT makes it very clear, but I'm happy to make it a "don't need to", if that's preferred. Including the preceding paragraph for context, that would look something like:
|
I like this better. I want to avoid checkers thinking this is telling them to flag an error for something like this. |
- add case where aria-selected="false" is used on focused item
I'm pretty confused by this, actually. Shouldn't For authors, it seems to me that the safest, most readable, and most cross-UA-friendly way to handle |
I do not think this is a good idea. As soon as a single selection element has the focus, AT will know which item was selected even without aria-selected. But what if I read with the virtual cursor of the screen reader or open the element overview and the element does not have the focus. Even then I want to perceive the selected item correctly and this is only possible with aria-selected. Therefore I would say that aria-selected must always be present |
Ok, I'm convinced that this new sentence could do more harm than good.
It doesn't actually say that it is used in single-selection widgets where selection follows focus. In fact, the line about "The selection normally follows the focus, and is managed by the user agent." seems to imply otherwise. This is reinforced by the next paragraph, which confusingly says:
So how can we make this clearer (and more robust)? Do we want to say something along the lines of the UA (and AT?) behavior being "fallback" behavior for when the author doesn't set aria-selected? Also, why would assistive technologies convey implicit selection if the user agent was already doing it? There's something very unclear in here, and I'd like to clean it up somehow. |
Hi @carmacleod |
I think the language needs to be updated to specifically address widgets where selection does not follow focus. I am specifically concerned about a tree where not all items are selectable and selection does not follow focus. In such a tree, aria-selected is required on all selectable elements. If none are marked with aria-selected=true and focus is on an item that is not selectable, the current spec language could be read as saying it is OK for the user agent to convey implicit selection for that item. Note that treeitem does not have a default value for aria-selected, so by default a treeitem is not selectable. By comparison, all options are selectable. What I don't understand is how the user agent or assistive tech are supposed to know if selection follows focus or not. The only widgets where it seems like that might be feasible are listbox and tablist. But, that rules out the possibility of a single select where nothing is selected. It might the be the case that the only way to make this unambiguous is to ensure that an item is only considered selected if it has aria-selected set to true. As soon as we allow for the possibility that focus implies selection, problems arise. One other issue: If we tell authors they do not have to set aria-selected to true in a single select where selection follows focus, how does an AT know which item is selected if the widget does not contain focus? |
Also in a tablist, focusing is not identical to aria-selected, see https://www.w3.org/TR/wai-aria-practices-1.2/examples/tabs/tabs-2/tabs.html And for all elements (including listbox and tablist) the selected item should be perceptible even without focusing. I already mentioned this in the comment above (and in #1094) and you also mentioned this in the next paragraph. Therefore I think that aria-selected should always be used |
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.
I think #799 should be decided before considering this PR; #799 has important ramifications.
However, the more I consider this PR, it seems deeply problematic that the user agent could "automatically" change selection. If focus and selection are one in the same, then there is no need for selection. So, just communicate focus and let selection remain undefined. If selection has meaning, require the author to specify it. The browser should not be guessing about selection and then changing the widget for the author.
Even if we tell authors they do not need to set aria-selected when they intend selection to follow focus, then user agents would have to modify the web page or the selected state will be lost on blur. I think that is inconsistent with ARIA's contract with authors and user agents.
If the user agent were going to change selection automatically, We would also need to be specific about what is meant by focus -- don't forget about aria-activedescendant.
BTW, I also just noticed that aria-multiselectable does not have an undefined value. That means that by default, the following widgets are assumed to contain selectable items:
- grid
- listbox
- tablist
- tree
- treegrid
In other words, unless we give aria-multiselectable a default value of undefined, these are all single-selects by default. Grid, tree, and treegrid support non-selectable items. Browsers can't assume that selection follows focus in these single-selects because it can't assume the items are selectable. So, at a minimum, this PR needs to be explicit that this special condition of not having to specify selection only applies to option and tab. Of course, if we merge #799, it might only apply to tab.
This PR has been superseded by the work going on in #1340 |
…where selection follows focus
This change attempts to address one small aspect of #1052
Preview | Diff