-
Notifications
You must be signed in to change notification settings - Fork 139
Clarify Accessibility Parent-Child Relationships for menu, group, and menuitem #2483
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for wai-aria ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: Peter Krautzberger <[email protected]>
Co-authored-by: Peter Krautzberger <[email protected]>
fix typo
@np-at to review as well! |
actually, taking myself off as a reviewer since we have so many others. |
@pkra, I just realized the same issue affects tree/group/treeitem structures. Should we include this change in this PR or create a separate one? |
@giacomo-petri sounds good. Hopefully it's simpler since #2094 prevents group as child of tree. |
index.html
Outdated
However, when a <code>group</code> is used in the context of a <rref>listbox</rref>, for example, authors MUST limit its children to <rref>option</rref> elements. Similarly, when a | ||
<code>group</code> is used in the context of a <rref>menu</rref> or <rref>menubar</rref>, authors MUST limit its <a>accessibility descendants</a> to <rref>menuitem</rref>, | ||
<rref>menuitemcheckbox</rref>, <rref>menuitemradio</rref> and <rref>separator</rref>, with only elements of role <rref>generic</rref>, <rref>group</rref>, and | ||
<rref>none</rref> intervening. Therefore, proper handling of <code>group</code> by authors and assistive technologies is determined by the context in which it is provided. |
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.
Coming back to this I'm not sure about this addition. "MUST limit its accessibility descendants" seems too strong - groups can have other descendants because, e.g., menuitem does not have any restrictions on its descendants.
IIRC we're really after "donut scoping". If that's the case I'm wondering if this addition is necessary. Does donut scoping not follow from the new requirements on menuitem etc now that we have accessibility ancestor?
If that's the case, then perhaps a note is more appropriate, describing this effect. (There could be a follow up issue to do the same with listbox and option.)
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.
Ah, I think what I wrote is not right either. Maybe children instead of descendants? E.g., "if a group has an accessibility ancestor of role menu, then allowed children are ...".
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.
In the working group meeting, I suggested using "accessibility children", but now I realize that can't quite be used the way I suggested, so I took a try at re-writing this whole section, which doesn't solve Peter's problem of making it "less wordy" but it does make it more clear, at least to me:
A set of user interface objects that is not intended to be included in a page summary or table of contents by assistive technologies.
Contrast with region, which is a grouping of user interface objects that will be included in a page summary or table of contents. If a section is significant enough to warrant inclusion in the web page's table of contents, the author SHOULD assign it a role of region or a standard landmark role.
Authors SHOULD use a group to form a logical collection of items in a widget, such as children in a tree widget forming a collection of siblings in a hierarchy. Authors MAY nest group elements.
The proper handling of group by authors and assistive technologies is determined by the context in which it is provided. For example, when a group is the accessibility child of a menu or menubar, authors MAY nest additional groups, however, the accessibility children of the innermost group MUST be limited to menuitems, menuitemcheckboxs, menuitemradios and separators. Whereas when a group is the accessibility child of a listbox, authors MUST NOT nest groups and MUST limit the groups accessibility children to option elements.
I don't think "accessibility descendant" quite works here, because we never want to say something about all descendants.
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.
Applied @spectranaut suggestion
index.html
Outdated
@@ -6200,6 +6202,10 @@ <h4>Plain HTML or Polyfill DOM Result of the MathML Quadratic Formula</h4> | |||
</p> | |||
<p>To be <a>keyboard accessible</a>, authors SHOULD manage focus of descendants for all instances of this <a>role</a>, as described in <a href="#managingfocus">Managing Focus</a>.</p> | |||
<p>Elements with the role <code>menu</code> have an implicit <pref>aria-orientation</pref> value of <code>vertical</code>.</p> | |||
<p class="note"> | |||
The <code>menu</code> <a>role</a> allows only role <rref>menuitem</rref>, <rref>menuitemcheckbox</rref>, <rref>menuitemradio</rref>, and <rref>separator</rref> as | |||
<a>accessibility descendants</a>, with only elements of role <rref>generic</rref>, <rref>group</rref>, and <rref>none</rref> intervening. |
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.
As above, I think menu can have other descendants (below e.g. menuitem). In which case this should be rephrased to describe the effects of donut scoping.
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.
Reading this I think I finally understand your concern @pkra. This is hard to write.
But since it's a note, maybe it can be more informal, here is a suggestion:
Let's call the elements that are contained in a menu and have roles menuitems, menuitemcheckboxes, menuitemradios or separator the "items" of that menu. These items can be arranged for logical purposes with groups, or styling purposes with generics. However, no semantically meaningful elements other than group are allowed between the individual items of the menu and the element with role menu. This is similar to the definition and constraints of "accessibility children", however, along with allowing intervening elements of role generic or none, we allow intervening elements of role group.
Also, I realize, the "allowed accessibility children" isn't clear enough. "Allowed accessibility children" only tells you what the next accessibility child should be. So if we add to that list "group with the accessibility child of group", then it's not clear that the child of THAT group MUST be either a group or (....). Is it possible to say this without being recursive?
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.
@spectranaut, I think your suggestion of replacing the term "accessibility descendants" with "accessibility children" reflects the intended requirement. The "first level of accessibility children" of a menu must consist only of menuitem, menuitemcheckbox, menuitemradio, or separator, and generic, group, or none are permitted as structural elements between these roles and the menu (but they do not count as "first-level accessibility children". While this is always true for generic and none, it's not inherently true for group, so we may want to add a note to clarify that explicitly).
To make this clearer, we may also add a note stating that other roles may appear as descendants of a menu, but they must not be accessibility children of the menu itself. We can refer to @spectranaut’s example involving the group role in this comment with other examples to illustrate that point in a note.
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.
Did you want to iterate on the note to add your suggestions, then? Would be nice to get this landed soon :)
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.
@spectranaut @pkra,
please take another look to see if it works now.
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.
looks good to me!
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.
Updated
index.html
Outdated
@@ -6304,6 +6312,10 @@ <h4>Plain HTML or Polyfill DOM Result of the MathML Quadratic Formula</h4> | |||
</p> | |||
<p>To be <a>keyboard accessible</a>, authors SHOULD manage focus of descendants for all instances of this <a>role</a>, as described in <a href="#managingfocus">Managing Focus</a>.</p> | |||
<p>Elements with the role <code>menubar</code> have an implicit <pref>aria-orientation</pref> value of <code>horizontal</code>.</p> | |||
<p class="note"> | |||
The <code>menubar</code> <a>role</a> allows only role <rref>menuitem</rref>, <rref>menuitemcheckbox</rref>, <rref>menuitemradio</rref>, and <rref>separator</rref> as | |||
<a>accessibility descendants</a>, with only elements of role <rref>generic</rref>, <rref>group</rref>, and <rref>none</rref> intervening. |
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.
Sames as above for menu.
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.
updated together with menu
index.html
Outdated
<li><rref>group</rref> with <a>accessibility child</a> <rref>menuitem</rref></li> | ||
<li><rref>group</rref> with <a>accessibility child</a> <rref>menuitemradio</rref></li> | ||
<li><rref>group</rref> with <a>accessibility child</a> <rref>menuitemcheckbox</rref></li> | ||
<li><rref>group</rref> with <a>accessibility child</a> <rref>separator</rref></li> |
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 we should be able to reduce this to just group's again.
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.
what about phrasing it as
"group as intervening role"
?
My concern is that if we just list "group" without clarification, some authors, especially those who skip over the note, might incorrectly assume that this kind of structure is valid:
<div role="menu">
<div role="group">
<a href="...">...</a>
<input type="checkbox" ...>
</div>
</div>
Since WCAG notes are non-normative, there's a real chance the note will be overlooked entirely. By explicitly mentioning "intervening role," we at least raise a red flag and prompt them to think twice (and read the note).
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 like that idea!
Discussed in today's meeting: https://www.w3.org/2025/07/03-aria-minutes.html#3a9f |
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.
Thanks for this effort @giacomo-petri! I've contributed some ideas...
index.html
Outdated
However, when a <code>group</code> is used in the context of a <rref>listbox</rref>, for example, authors MUST limit its children to <rref>option</rref> elements. Similarly, when a | ||
<code>group</code> is used in the context of a <rref>menu</rref> or <rref>menubar</rref>, authors MUST limit its <a>accessibility descendants</a> to <rref>menuitem</rref>, | ||
<rref>menuitemcheckbox</rref>, <rref>menuitemradio</rref> and <rref>separator</rref>, with only elements of role <rref>generic</rref>, <rref>group</rref>, and | ||
<rref>none</rref> intervening. Therefore, proper handling of <code>group</code> by authors and assistive technologies is determined by the context in which it is provided. |
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.
In the working group meeting, I suggested using "accessibility children", but now I realize that can't quite be used the way I suggested, so I took a try at re-writing this whole section, which doesn't solve Peter's problem of making it "less wordy" but it does make it more clear, at least to me:
A set of user interface objects that is not intended to be included in a page summary or table of contents by assistive technologies.
Contrast with region, which is a grouping of user interface objects that will be included in a page summary or table of contents. If a section is significant enough to warrant inclusion in the web page's table of contents, the author SHOULD assign it a role of region or a standard landmark role.
Authors SHOULD use a group to form a logical collection of items in a widget, such as children in a tree widget forming a collection of siblings in a hierarchy. Authors MAY nest group elements.
The proper handling of group by authors and assistive technologies is determined by the context in which it is provided. For example, when a group is the accessibility child of a menu or menubar, authors MAY nest additional groups, however, the accessibility children of the innermost group MUST be limited to menuitems, menuitemcheckboxs, menuitemradios and separators. Whereas when a group is the accessibility child of a listbox, authors MUST NOT nest groups and MUST limit the groups accessibility children to option elements.
I don't think "accessibility descendant" quite works here, because we never want to say something about all descendants.
index.html
Outdated
@@ -6200,6 +6202,10 @@ <h4>Plain HTML or Polyfill DOM Result of the MathML Quadratic Formula</h4> | |||
</p> | |||
<p>To be <a>keyboard accessible</a>, authors SHOULD manage focus of descendants for all instances of this <a>role</a>, as described in <a href="#managingfocus">Managing Focus</a>.</p> | |||
<p>Elements with the role <code>menu</code> have an implicit <pref>aria-orientation</pref> value of <code>vertical</code>.</p> | |||
<p class="note"> | |||
The <code>menu</code> <a>role</a> allows only role <rref>menuitem</rref>, <rref>menuitemcheckbox</rref>, <rref>menuitemradio</rref>, and <rref>separator</rref> as | |||
<a>accessibility descendants</a>, with only elements of role <rref>generic</rref>, <rref>group</rref>, and <rref>none</rref> intervening. |
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.
Reading this I think I finally understand your concern @pkra. This is hard to write.
But since it's a note, maybe it can be more informal, here is a suggestion:
Let's call the elements that are contained in a menu and have roles menuitems, menuitemcheckboxes, menuitemradios or separator the "items" of that menu. These items can be arranged for logical purposes with groups, or styling purposes with generics. However, no semantically meaningful elements other than group are allowed between the individual items of the menu and the element with role menu. This is similar to the definition and constraints of "accessibility children", however, along with allowing intervening elements of role generic or none, we allow intervening elements of role group.
Also, I realize, the "allowed accessibility children" isn't clear enough. "Allowed accessibility children" only tells you what the next accessibility child should be. So if we add to that list "group with the accessibility child of group", then it's not clear that the child of THAT group MUST be either a group or (....). Is it possible to say this without being recursive?
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.
One minor thing!
Co-authored-by: Valerie Young <[email protected]>
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 approve, with removing the extra rows for group and just put "group as intervening role" -- thought I wonder now if we should define "intervening" somewhere...
@spectranaut, I agree that we likely need a definition for "intervening," but it's already used 7 times in the specs, though always referring to generic or none. That said, I think the current wording for group doesn't add complexity and still aligns with the intent of the others, even if the context and outcome differ. Should we consider trying adding that definition (since it also impacts generic intervening) in a separate PR? |
<p> | ||
Authors MAY nest <code>group</code> elements. If a section is significant enough to warrant inclusion in the web page's table of contents, the author SHOULD assign it a <a>role</a> of | ||
<rref>region</rref> or a <a href="#landmark_roles">standard landmark role</a>. | ||
Authors SHOULD use a <code>group</code> to form a logical collection of items in a <a>widget</a>, such as children in a tree widget forming a collection of siblings in a hierarchy. |
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.
Authors SHOULD use a <code>group</code> to form a logical collection of items in a <a>widget</a>, such as children in a tree widget forming a collection of siblings in a hierarchy. | |
Authors SHOULD use a <code>group</code> to form a logical collection of items in a <a>widget</a>, such as children in a treeitem forming a collection of siblings in a hierarchy. |
group is not allowed in tree, only treeitem (I realize this was not a change in this PR).
</p> | ||
<p> | ||
The proper handling of <code>group</code> by authors and assistive technologies is determined by the context in which it is provided. For example, when a <code>group</code> is the | ||
<a>accessibility child</a> of a <code>menu</code> or <code>menubar</code>, authors MAY nest additional <code>group</code> elements. However, the <a>accessibility children</a> of the |
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 the new content (However, ...) is good addition but it should be a note and not using normative language. As my suggestion for tree widgets shows, it's easy for such language to be out of date. I think normative statements on roles should be limited to their own sections.
<code>menu</code>. This allows authors to organize menus logically using groups or to style them using generic containers. However, aside from <rref>group</rref>, no other semantically | ||
meaningful roles may intervene between the allowed child roles and the <code>menu</code>. This structure mirrors the concept of "accessibility children", but explicitly permits | ||
<rref>group</rref> in addition to <rref>generic</rref> and <rref>none</rref> as intervening elements. | ||
</p> |
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 admit I'm still unhappy with this.
I don't like how the second sentence contradicts the first sentence's "allows only roles". I don't like "structural" in "structural element" nor how generics are mentioned (which can always be added after all so here a reader might wonder what is special about mentioning them again).
I also do not like the duplication of this language in menubar; it will invariably fall out of sync.
I realize we cannot get to something as tight as we have for trees, but I think we should work on this concept rather than adding more complicated language like this throughout the spec.
Still, I don't want to keep blocking this.
<li><rref>group</rref> with <a>accessibility child</a> <rref>menuitem</rref></li> | ||
<li><rref>group</rref> with <a>accessibility child</a> <rref>menuitemradio</rref></li> | ||
<li><rref>group</rref> with <a>accessibility child</a> <rref>menuitemcheckbox</rref></li> | ||
<li><rref>group</rref> as intervening role</li> |
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 second the idea of adding a definition (later).
I'm not sure why my last review is marked "requesting changes" - I'm guessing the suggested change is to blame. I don't oppose merging this as is, despite remaining somewhat unhappy with the language. |
Closes #2438
The current specifications for menu and menubar contradict those for menuitem, menuitemcheckbox, and menuitemradio.
Specifically, the following structure is allowed under the menu role but not when considering the menuitem role:
This PR clarifies that this structure is indeed allowed.
Additionally, it explicitly clarifies in a note that the following example, where a group contains a button and an input as accessibility children, is not permitted. This prevents ambiguity by making it clear that having at least one menuitem as an accessibility child of the group does not justify including other unrelated elements, which was not clearly stated.
This update refines the specifications for menu, menubar, menuitem, menuitemcheckbox, and menuitemradio roles consistently.
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.
Preview | Diff