Open josepharhar opened 1 month ago
This issue provides a use case for not using the label attribute when rendering: https://github.com/openui/open-ui/issues/1118
Right now the label attribute is not used for rendering, but does get copied into the default/fallback button, which is probably not good and should be fixed after we decide what to do here.
<select>
<option label=label>text</option>
</select>
In the spec PR, I'm already saying that options don't use the label attribute to render: https://whatpr.org/html/10629/rendering.html
An option element is expected to be rendered by displaying the element's label, indented under its optgroup element if it has one. If the option is being rendered in a select which is being rendered as a drop-down box with base appearance, then the option is expected to render all of its children rather than by displaying its label.
Proposed resolution: Don't use the option's label attribute to render anything anywhere in the new select.
It seems unfortunate to change this behavior from how non-custom select works.
Is there another case besides #1118 that needs a label distinct from the children?
Is label
relevant to a11y or would that be aria-label
and if it's the latter, then is the keyboard case in #1118 an a11y concern and could it therefore use aria-label
? (Unfortunately, it looks like aria-label
isn't used for keyboard navigation in the normal select)
label is not an a11y-specific attribute, in that it was a method to provide a visible label, rather than using nested text, for an option.
aria-label aside, the accName of the option either comes from the label - which produced visible text 'in' the option, or the visible text an author provides within the option. so that's why it's not an a11y-feature, because they were two methods to render a visible label. previously, the label attr took precedent over the visible text, so the visible text an author provided would be ignored, and the label text would be present within the option. but for calculating the accname, that visible text was all that mattered (again, aria-label aside and the fact it wasn't even consistently used by all browsers/AT to modify an accName - since the UA provided options weren't necessarily 1:1 matches with the markup that someone wrote) but in the context of a datalist, an option can have visible text AND a label attribute's text both made visually available in an option. I've mentioned in the current select PR that this distinction is lost with the updates to the content model for options. arguably, this similar behavior could be useful for the new customizable select too...
linking this issue to my HTML AAM PR for option element mapping updates, - https://github.com/w3c/aria/pull/2365
The Open UI Community Group just discussed select: How should we render `<option label=label>text`?
, and agreed to the following:
RESOLVED: render the label attribute for options when it is present, regardless of the select's appearance value, just like it already does. also the label attribute is bad.
In the pre-customizable-select chromium implementation, option elements only render text content by manually collecting it from their descendants. If there is a label attribute, then the text cotent of descendant nodes is ignored and the text in the label attribute is rendered instead.
There is currently some code in chromium which tries to preserve this rendering behavior when not inside a customizable select, but doesn't do this label overwriting behavior and allows all child nodes to be rendered normally when inside a customizable select. It's not very performant right now and I'm currently trying to find ways to work around it.
It occurred to me that this has never been discussed before and could affect how I implement this - how should we render
<option label=label>text</option>
? Should "label" or "text" be rendered?This would also affect cases like
<option label=label><img src=...><span>text</span> more text</option>
- if we choose to render "label", then the img and other child content would not be rendered.If we don't render the label attribute, then should that label attribute be used in the accessibility tree instead of the actual child nodes? Is there a use case for that? @scottaohara
Related: https://github.com/openui/open-ui/issues/558