Skip to content

Conversation

giacomo-petri
Copy link
Contributor

@giacomo-petri giacomo-petri commented Mar 21, 2025

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:

<div role="menu">
	<div role="group">
		<span role="menuitem">Item 1</span>
		<div role="group">
			<span role="menuitem">Item 2</span>
			<span role="menuitem">Item 3</span>
		</div>
	</div>
</div>

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.

<div role="menu">
	<div role="group">
		<span role="menuitem">Item 1</span>
		<div role="group">
			<span role="menuitem">Item 2</span>
			<span role="menuitem">Item 3</span>
		</div>
		<button>Test</button>
		<input type="text aria-label="Test">
	</div>
</div>

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.

  • "author MUST" tests:
  • "user agent MUST" tests:
  • Browser implementations (link to issue or commit):
    • WebKit:
    • Gecko:
    • Blink:
  • Does this need AT implementations?
  • Related APG Issue/PR:
  • MDN Issue/PR:

Preview | Diff

Copy link

netlify bot commented Mar 21, 2025

Deploy Preview for wai-aria ready!

Name Link
🔨 Latest commit 7048eb6
🔍 Latest deploy log https://app.netlify.com/projects/wai-aria/deploys/6894db20b48ac70008cbe264
😎 Deploy Preview https://deploy-preview-2483--wai-aria.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkra pkra added the clarification clarifying or correcting language that is either confusing, misleading or under-specified label Mar 21, 2025
pkra
pkra previously requested changes Mar 21, 2025
giacomo-petri and others added 4 commits March 21, 2025 20:53
@giacomo-petri giacomo-petri requested a review from pkra March 21, 2025 20:14
@giacomo-petri giacomo-petri dismissed pkra’s stale review March 21, 2025 20:14

suggestions applied

@spectranaut
Copy link
Contributor

@np-at to review as well!

@scottaohara scottaohara removed their request for review March 27, 2025 17:27
@scottaohara
Copy link
Member

actually, taking myself off as a reviewer since we have so many others.

@giacomo-petri
Copy link
Contributor Author

@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?

@pkra
Copy link
Member

pkra commented Apr 3, 2025

@giacomo-petri sounds good. Hopefully it's simpler since #2094 prevents group as child of tree.

@spectranaut spectranaut moved this from All PRS to Needs Consensus/Review in ARIA Normative PR Tracking Jun 13, 2025
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.
Copy link
Member

@pkra pkra Jun 14, 2025

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.)

Copy link
Member

@pkra pkra Jun 14, 2025

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 ...".

Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Member

@pkra pkra Jun 14, 2025

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkra, @spectranaut

@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.

Copy link
Contributor

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 :)

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

Copy link
Contributor Author

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.
Copy link
Member

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.

Copy link
Contributor Author

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>
Copy link
Member

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.

Copy link
Contributor Author

@giacomo-petri giacomo-petri Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkra

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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea!

@pkra pkra added the Agenda label Jun 14, 2025
@spectranaut
Copy link
Contributor

Discussed in today's meeting: https://www.w3.org/2025/07/03-aria-minutes.html#3a9f

Copy link
Contributor

@spectranaut spectranaut left a 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.
Copy link
Contributor

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.
Copy link
Contributor

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?

@jnurthen jnurthen removed the Agenda label Jul 15, 2025
@spectranaut spectranaut self-requested a review August 4, 2025 15:47
Copy link
Contributor

@spectranaut spectranaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing!

Copy link
Contributor

@spectranaut spectranaut left a 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...

@giacomo-petri
Copy link
Contributor Author

@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?

@spectranaut spectranaut requested a review from pkra August 26, 2025 20:25
<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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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).

@pkra
Copy link
Member

pkra commented Aug 27, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification clarifying or correcting language that is either confusing, misleading or under-specified spec:aria
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

Group as allowed acc child of role menu if acc child of menuitem
5 participants