Skip to content
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

Group as allowed acc child of role menu if acc child of menuitem #2438

Open
giacomo-petri opened this issue Feb 13, 2025 · 5 comments · May be fixed by #2483
Open

Group as allowed acc child of role menu if acc child of menuitem #2438

giacomo-petri opened this issue Feb 13, 2025 · 5 comments · May be fixed by #2483
Assignees

Comments

@giacomo-petri
Copy link
Contributor

Describe your concern

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

Per ARIA specs, the role="menu" accepts group as acc child only if one of the following is true:

but it's unclear whether a group containing another group (group > (or with generic intervening) group) is acceptable. As written, it appears to be allowed as long as the parent group has at least one accessible child menuitem, but I'm not sure if that was the intended meaning.

@giacomo-petri
Copy link
Contributor Author

@giacomo-petri to test it and provide evidence

@aardrian
Copy link
Contributor

If you need testing on AT you don't have, hit me up.

@spectranaut
Copy link
Contributor

Discussed in today's ARIA meeting: https://www.w3.org/2025/02/20-aria-minutes#56b0

@giacomo-petri
Copy link
Contributor Author

giacomo-petri commented Feb 27, 2025

I've revisited the issue I previously opened and have some important observations to add.

As mentioned earlier,

Per ARIA specs, the role="menu" accepts group as acc child only if one of the following is true:

My initial focus was on the menu > group > menuitem + group structure due to a specific scenario. The specs are unclear on whether having a menuitem as a child is enough to also permit a group as its sibling. However, from a broader perspective, the current wording appears to allow every role as long as the group contains at least one menuitem. For example:

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

Here, the role group has a menuitem as an accessibility child, which seems to be allowed per the specs (or at least not prohibited). However, when testing the code above, the structure becomes unclear, as the relationships between elements are not well-defined. IMO the intent of the spec seems to be that role group should contain only menuitem, menuitemradio, or menuitemcheckbox. If the intent is different and broader usage is intended, the group role should specify what additional elements are allowed when it is an accessibility child of menu, rather than allowing everything.

Going back to my original point, the menu > group > menuitem + group structure, based on this, should not be valid.

Additionally, when considering this topic from the child-parent relationship perspective (rather than the parent-child perspective), the specs state that a menu item can only have a group as its parent if:

group with accessibility parent menu
group with accessibility parent menubar

So while the menu role spec does not explicitly prohibit group > menuitem + group:has(> menuitem) where the last group has a child menuitem, the menuitem role does.

@jnurthen
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants