Repository navigation
[html-aam] Addition: selectedcontent element - #2344
scottaohara wants to merge 11 commits into
Conversation
I recreated the [original PR](w3c/html-aam#566) by @josepharhar The `<selectedoption>` element is part of the [customizable select feature](whatwg/html#9799) and is being added to HTML [here](whatwg/html#10633). ## Implementation * WPT tests: web-platform-tests/wpt#45096 * Implementations (link to issue or when done, link to commit): * WebKit: TODO * Gecko: TODO * Blink: https://chromium.googlesource.com/chromium/src/+/18b5eac27b14b409503aa8047cf9358082a0e0df Co-authored-by: Joey Arhar @josepharhar
✅ Deploy Preview for wai-aria ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@jcsteh we need to discuss the mappings for this new element, if you wanted to take a look now and share your initial thoughts? |
|
I'm finding it challenging to fathom mappings for this because I don't quite understand some of the use cases here.
|
|
hey @jcsteh, thanks for the questions. Right now, it's generally assumed that this would be a generic or presentational element by default, it's meant to be the visual representation of the chosen option / value for the select. In the HTML spec, the only valid place this element can be used is as a descendant of a button that is the first child of a select element. So in many cases it should just represent the chosen value. But, the reason I wanted to get people to have a think on this is because HTML does allow all global attributes on this element, and being an element now, rather than just a text string, I'm not entirely sure what should happen, if anything, if developers were to use additional global attributes or even ARIA attributes on the element. For instance, If someone were to do the above, this should be exposed no differently than the current mappings for the select element. The chosen option's content would be rendered in the selectedoption element - this being the img alt=two. So a select with the name "example" per its label and a value of "two" per the alt text of the image within the option. But what should happen if someone were to do: Should any of the attributes be respected? Should they be used to modify the value that the select/combobox exposes? Should the value that's exposed by the select change if someone were to alter the visible children of the selectedoption - either adding content that wasn't part of the option element's label/value, or removing content that was? At first I thought maybe this would be fine to treat similar to the slot element, but slot isn't consistent in how it's treated between browsers (some allowing it to be focused, or have the title update it's accname, though aria-label at least seems ignored in firefox and chrome). So, just being like "oh it can be like slot, that'll be fine" seemed like maybe not the best assumption to make. So, that hopefully answers some of your questions / provides some more context to why I wanted others to weigh in on this, as just mapping this to 'generic' or 'none' would seem like the thing to do here for the default state - but if people start modifying the element / its contents, that's where I'm realizing there hasn't been any real discussion on that, that I'm aware of. To more directly answer your 3 points, to make sure nothing's left out:
|
Thanks for the comprehensive answers. :)
Ah interesting. My understanding is that
Per the above, I don't think so.
Interesting. So the spec guarantees that All of that said, now I'm more puzzled about how we should handle a |
|
Regarding #2, the way it works in Chrome right now, is that focus goes to the button instead of the select, when the button exists. As a result the A11y tree in Chrome has to have code that remaps focus from the button to the select object in the a11y tree. We likewise remap actions like default action / click and focus requests from the select to that button, if it erxists. Regarding #3, if the split button use case is no longer valid, then we should suggest to folks working on this that this is just about styling, and that pseudo elements would be a better way to style the button and possibly visible value within. If we do that, then I believe issue #1 and #2 go away. |
It sounds reasonable to me to ignore this and always expose the value of the selected option.
Yes, this is the way. I also added code in chrome to set delegatesFocus on the select element when there is a child button which is what makes the focus go to the button element instead of the select element.
Without the author provided button and selectedoption element, then you don't currently get elements cloned into the button, only text content, and there's no way to style the option and button differently. So if you want your img element to be copied into the button without using script, this is the only way. Cloning all the "rich" content into the button without this would require us to clone content into the user-agent ShadowRoot of the select element and providing a way for authors to have full styling capabilities into the ShadowRoot, both of which are problematic technologies that may or may not ever exist. |
|
What happens if the selected option has a child button or link? Will that also get cloned into the selectedoption's subtree? Will they also be focusable? |
Yes that will get cloned because the algorithm doesn't discern between what kinds of elements it clones. I suppose it will be focusable assuming that nested buttons/links are individually focusable. However, putting interactive content inside an option element like this is already against the content model, so I don't see how this makes the situation any different or worse. |
That's a use case that I'd eventually like to support for buttons and links. We'll be able to make it accessible with an update to screen readers, and if it's the reason people will need to use a JS-based solution, we'll be losing an opportunity for better accessibility. IMO what should happen from a practical POV is that any descendant buttons and links are stripped out of the subtree when it's copied to the selectedoption. |
I suppose thats something we could try to change later when we get to the eventual support of buttons and links, but right now the algorithm is very simple and just clones everything. |
|
I think we discussed the need for a way to set the human-readable-text value of options separately from the text content of Assuming we figure that out at some point, would that attribute also carry over to the I dunno if that's in scope for this PR, especially since neither HTML AAM nor Core AAM spec how to calculate the value for combobox/select. Though with the more complicated |
the important thing to note about this though is that visually these items can be seen, they can be focused, but they will not be announced by screen readers - at least in my testing with JAWS/NVDA and Chrome/Edge. Unlike nesting links/buttons within options, where common use cases for that are performing an action on/related to the option, while the popup is open - I cannot think of a single instance of ever seeing these commands returned along with the chosen value to a custom combobox/select. i wonder, if it's out of scope to change the cloning algorithm at this time, should there at least be important UA styles to display none instances of elements that don't adhere to the content model, if rendered within a selectedoption? |
|
need to incorporate resolution from #2368 in this PR as well |
- update pr from selectedoption to selectedconent - map to the generic role (in the event someone misuses the element and declares it outside of its expected location, as a child of the button part within a select. - note that in its intended usage, the button part will be inert, and thus any global html or aria attributes used on the element would not be exposed to the a11y api
|
updated w3c/html-aria#528 to match these changes as well |
cookiecrook
left a comment
There was a problem hiding this comment.
WebKit pre-req WebKit/standards-positions#386
|
thanks @josepharhar - changed the title of the PR |
closes #2382 and is related to #2344 / #2369 This PR adds aria-valuetext as a supported property for the combobox role. the `aria-valuetext` definition is slightly updated to indicate that the attribute can be used on other supported roles. I'm not sure if we want to do any further updates to that section in this PR - or if that really should be handled in a larger PR to resolve #711
closes #2382 and is related to #2344 / #2369 This PR adds aria-valuetext as a supported property for the combobox role. the `aria-valuetext` definition is slightly updated to indicate that the attribute can be used on other supported roles. I'm not sure if we want to do any further updates to that section in this PR - or if that really should be handled in a larger PR to resolve #711
keithamus
left a comment
There was a problem hiding this comment.
All very reasonable and straightforward. 👍
| <td> | ||
| <p> | ||
| The `selectedcontent` element is a declarable child of the `button` part of a custom styled `select` element. The `button` part of the `select` element's anatomy, and thus the | ||
| `selectedcontent` element descendant, are inert. |
There was a problem hiding this comment.
inert or presentational children?
There was a problem hiding this comment.
inert was what had been decided / how it is implemented in chrome. the parent select element is the interactive control, and anything nested within its button part is meant to represent that button, not be its own button or contain any other interactive content.
| <tr> | ||
| <th>[[wai-aria-1.2]]</th> | ||
| <td> | ||
| <div class="general"><a class="core-mapping" href="#role-map-generic">`generic`</a> role</div> |
There was a problem hiding this comment.
I take no issue with mapping to generic, but will stop short of an approving review since the link WebKit standards position is still open.
There was a problem hiding this comment.
The webkit standards position has been marked positive
There was a problem hiding this comment.
I don't really understand why we're mapping this to generic if we're explicitly saying that the button and its selectedcontent descendant are inert. Per the spec, "Nodes that are inert are not exposed to an accessibility API." If it's not exposed at all, it isn't generic; it just doesn't exist in the accessibility tree at all, like aria-hidden or display: none. In contrast, a generic node may (but not necessarily) be exposed in the accessibility tree.
There was a problem hiding this comment.
The selectedcontent element is supposed to be used inside the inert button. You're currect that when it's used correctly it won't be included in the accessibility tree, so it probably doesn't matter how we map this element. I figure that calling it generic is the easiest way to give it a default and say that it doesn't matter, but I'm not opposed to any sort of alternative or omitted mapping.
There was a problem hiding this comment.
yes, @jcsteh, if the element is used within the select's inert button part, it is inert - but if it were to be used outside of that intended context, it wouldn't be inert - it'd be generic.
The comment in this mapping (where you called out the awkward wording of descendant child, which i've now updated) explicitly states it's the button that is inert, and thus this element is inert when used as expected, as a child of the button part.
There was a problem hiding this comment.
That's fair, but honestly, this still seems a bit awkward to me. We're defining the mapping for the element here, but we give the role for the element when used outside of its expected context. The comments clarify that it should be inert in its expected context, but I'm concerned that this will still lead to confusion, given that the role is generally the "expected" case, not the exceptional one, unless the heading explicitly specifies the context. To put this another way, if I (with years of experience) got confused by this, it's likely that someone else will too, though I'm willing to accept my brain is uniquely weird. :)
I'd much prefer it if we could specify "generic (when used outside expected context; see comments)" or something like that. I don't feel strongly enough about this to block on it - the comments do mention it being inert - but it's a very strong recommendation.
There was a problem hiding this comment.
@jcsteh i think that's a reasonable suggestion.
Tbh, there are other elements that this should probably apply to as well. e.g., the style element is exposed as generic if someone were to set that to display: block.
What do you think of identifying selectedcontent and (in another PR) other roles that are exposed as generic, when used 'unexpectedly' as having a minimum role of generic?
There was a problem hiding this comment.
i think that's a reasonable suggestion.
Thanks for your forbearance. :)
What do you think of identifying selectedcontent and (in another PR) other roles that are exposed as generic, when used 'unexpectedly' as having a minimum role of generic?
That would require significant change to the language describing minimum role, which currently refers to a minimum role being "non-generic", a role that isn't "either none, presentation, or generic", dependent on "attributes which require a minimum role mapping", etc. I'm not convinced this would be any clearer conceptually than just specifying a role of generic when the element is used unexpectedly. That said, I don't really mind which way we go as long as this gets documented one way or another.
[Edit: Quoting to clarify context of comments.]
| <tr> | ||
| <th>[[wai-aria-1.2]]</th> | ||
| <td> | ||
| <div class="general"><a class="core-mapping" href="#role-map-generic">`generic`</a> role</div> |
There was a problem hiding this comment.
I don't really understand why we're mapping this to generic if we're explicitly saying that the button and its selectedcontent descendant are inert. Per the spec, "Nodes that are inert are not exposed to an accessibility API." If it's not exposed at all, it isn't generic; it just doesn't exist in the accessibility tree at all, like aria-hidden or display: none. In contrast, a generic node may (but not necessarily) be exposed in the accessibility tree.
| <tr> | ||
| <th>[[wai-aria-1.2]]</th> | ||
| <td> | ||
| <div class="general"><a class="core-mapping" href="#role-map-generic">`generic`</a> role</div> |
There was a problem hiding this comment.
yes, @jcsteh, if the element is used within the select's inert button part, it is inert - but if it were to be used outside of that intended context, it wouldn't be inert - it'd be generic.
The comment in this mapping (where you called out the awkward wording of descendant child, which i've now updated) explicitly states it's the button that is inert, and thus this element is inert when used as expected, as a child of the button part.
| <tr> | ||
| <th>[[wai-aria-1.2]]</th> | ||
| <td> | ||
| <div class="general"><a class="core-mapping" href="#role-map-generic">`generic`</a> role</div> |
There was a problem hiding this comment.
That's fair, but honestly, this still seems a bit awkward to me. We're defining the mapping for the element here, but we give the role for the element when used outside of its expected context. The comments clarify that it should be inert in its expected context, but I'm concerned that this will still lead to confusion, given that the role is generally the "expected" case, not the exceptional one, unless the heading explicitly specifies the context. To put this another way, if I (with years of experience) got confused by this, it's likely that someone else will too, though I'm willing to accept my brain is uniquely weird. :)
I'd much prefer it if we could specify "generic (when used outside expected context; see comments)" or something like that. I don't feel strongly enough about this to block on it - the comments do mention it being inert - but it's a very strong recommendation.
Co-authored-by: James Teh <jamie@jantrid.net>
|
🚀 Deployed on https://deploy-preview-2344--wai-aria.netlify.app |
🚀 Netlify Preview:
🔄 this PR updates the following sspecs:
I recreated the original HTML AAM repo PR
The
<selectedoption>element is part of the customizable select feature and is being added to HTML here.Implementation
Co-authored-by: Joey Arhar @josepharhar