-
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
[html-aam] Addition: selectedoption element #2344
base: main
Are you sure you want to change the base?
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 site 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 |
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.
WebKit pre-req WebKit/standards-positions#386
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