Update: legend to provide name to optgroup#2360
Conversation
In regards to the updated content model for the select element and its allowed children, an `optgroup` can have a `legend` element as its first child, and this `legend` needs to be able to name the `optgroup` similarly to how a `legend` names a `fieldset`. see: whatwg/html#10586
✅ Deploy Preview for wai-aria ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
open question in whatwg/html#10586 (comment) about what should take priority - legend or optgroup's label attr. if both end up being allowed / render - then one of these could be added to the accDescription computation - instead of ignoring one or combining them into one long name.
keithamus
left a comment
There was a problem hiding this comment.
Couple of minor formatting comments, but this LGTM from a spec position, modulo new resolutions from the WHATWG.
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
|
@keithamus would you mind taking another look? I've updated the ordering for the optgroup naming, and added new content to how a description should be calculated. cc @josepharhar as updates here related to my comments in the update content model for customized select PR |
|
examples for tests for how name/desc steps should work |
|
put back into the draft state as I need to revise the bits about how a |
If you have a recommendation for what to do in this case, let me know and/or comment on the crbug. I haven't implemented anything yet to account for the case where both are present. |
|
@josepharhar i think it's totally fine to only have one render / and have a preference for the legend element in this case since it'll allow for authors to do more.
|
revised to incorporate latest decisions on how the naming/desc should work
|
@scottaohara does this need implementation changes? If so I'll add the PR tracking list. |
|
Discussed briefly in last weeks meeting: https://www.w3.org/2025/06/26-aria-minutes.html#58a8 |
I'm not sure this is true. I don't see anything in the Gecko accessibility code that would currently support legend as a labelling child of optgroup. But maybe I'm missing something. @keithamus, can you clarify your thinking here? |
jcsteh
left a comment
There was a problem hiding this comment.
Overall, this looks good, but I think it needs some clarifications.
| <div class="relations"><span class="type">Relations:</span> `IA2_RELATION_LABEL_FOR` with the parent <a href="#el-fieldset">`fieldset`</a></div> | ||
| <div class="relations"> | ||
| <span class="type">Relations:</span> `IA2_RELATION_LABEL_FOR` with the parent <a href="#el-fieldset">`fieldset`</a> | ||
| or <a href="#el-optgroup">`optgroup`</a> |
There was a problem hiding this comment.
For clarity, I think we need to specify the reverse LABELLED_BY relation somewhere. For example, we do this for fieldset. We're somewhat inconsistent about where we document the relation. For IA2, we document LABELLED_BY in the <fieldset> section, but for UIA, we document LabeledBy in the <legend> section. That's an editorial issue we can sort out separately, but I think it does need to be documented somewhere, and I'd suggest documenting the IA2 relation in the <optgroup> section, since that's what we do for <fieldset>.
| <span class="type">Relations:</span> | ||
| `ATK_RELATION_LABEL_FOR` with parent <a href="#el-fieldset">`fieldset`</a> element | ||
| `ATK_RELATION_LABEL_FOR` with parent <a href="#el-fieldset">`fieldset`</a> | ||
| or <a href="#el-optgroup">`optgroup`</a> element |
There was a problem hiding this comment.
Ditto regarding the LABELLED_BY relation.
| </li> | ||
| <li> | ||
| or use the <a data-cite="accname-1.2/#mapping_additional_nd_te">text equivalent computation</a> of the subtree of the | ||
| first `legend` element if it was not used as the <a data-cite="accname-1.2/#dfn-accessible-name">accessible name</a>. |
There was a problem hiding this comment.
We should expose DESCRIBED_BY and DESCRIPTION_FOR relations if we do this. I think we have the same issue for table captions when used as description, but I guess we should address that separately.
I don't recall saying it's already implemented, but maybe I did? I'm not sure I can clarify further given that I don't remember. |
looks like Val updated the gecko status back in July. looking back at the minutes, I'm guessing this was just a misunderstanding/typo - as you said chrome implemented, and you were approving of the PR so that it could count as endorsement from mozilla. i've updated the OP to correct this |
|
thanks for the review on this @jcsteh - i'll work on these suggestions asap |
In regards to the updated content model for the select element and its allowed children, an
optgroupcan have alegendelement as its first child, and thislegendneeds to be able to name theoptgroupsimilarly to how alegendnames afieldset.see:
whatwg/html#10586
WPT - web-platform-tests/wpt#49645
Test, Documentation and Implementation tracking
Once this PR has been reviewed and has consensus from the working group, tests should be written and issues should be opened on browsers. Add N/A and check when not applicable.