act-rules.github.io icon indicating copy to clipboard operation
act-rules.github.io copied to clipboard

ARIA 1.2 mapping of div/span to role=generic causes lots of new failures

Open dd8 opened this issue 3 years ago • 4 comments

The ARIA required context role only considers parent/child relations in the accessibility tree https://www.w3.org/WAI/standards-guidelines/act/rules/ff89c9/proposed/

With ARIA 1.1 this means the following code passed the rule because the inner div, between list and listitem, had no implicit role and wasn't part of the ARIA tree:

<div role="list">
  <div>
	<div role="listitem">List item 1</div>
	<div role="listitem">List item 2</div>
  <div>
</div>

Edit: in the ARIA 1.1 draft of AAM div was specified as:

No corresponding role May not have an accessible object if has no semantic meaning

However HTML AAM was updated in https://github.com/w3c/html-aam/pull/348 to map div/span to the new ARIA 1.2 generic role.

That means both these lists produce an identical ARIA tree and both now fail the rule:

<div role="list">
  <div>
	<div role="listitem">List item 1</div>
	<div role="listitem">List item 2</div>
  <div>
</div>

<div role="list">
  <div role="generic">
	<div role="listitem">List item 1</div>
	<div role="listitem">List item 2</div>
  <div>
</div>

There will be a lot of pages using divs/spans without roles that passed previously - including many of the ARIA patterns at https://www.w3.org/WAI/ARIA/apg/patterns/.

These haven't suddenly become less accessible - so I think the rule needs to change.

This is related to https://github.com/act-rules/act-rules.github.io/issues/1985 and https://github.com/act-rules/act-rules.github.io/issues/1990

dd8 avatar Dec 19 '22 20:12 dd8

Yes, I think the generic role needs to be skipped over by the rule, this matches its definition.

In Alfa, we map DOM nodes to either Element or Container accessibility nodes, depending whether they have semantics or are purely structural. My solution will thus be to map generic DOM nodes to Container and that should work the same way 🤞

But this indeed hints that the rule should skip over generic elements (and/or that we need a definition of the accessibility tree or "owned by" that skip them).

Jym77 avatar Jan 05 '23 10:01 Jym77

agree that the generic role should be skipped by the rule. Even though they are "in the tree" does not mean it has any semantics to add to the tree.

sboptum avatar Jan 12 '23 15:01 sboptum

I think the rule works as intended. The weird thing about "generic" is that whether or not it's in the accessibility tree is left up to the browser. So unlike "presentation" which is never in the AXT, or "list" which is always in the tree (unless hidden), whether or not an element with the "generic" role is in the tree is left up to the browser. Most browsers do basically the same thing they do with presentational role conflict; if the generic element is focusable, or has a global attribute its included in the tree, if not its ignored.

I;e; This passes the rule:<div role="menu"> <div> <div role="menuitem">, but this fails it: <div role="menu"> <div tabindex="0"> <div role="menuitem">

Regardless, we should better explain this, and maybe have examples for it?

WilcoFiers avatar Feb 02 '23 10:02 WilcoFiers

core-aam says role=generic should be exposed by a11y API: https://w3c.github.io/core-aam/#role-map-generic

Chrome and FF both expose <div> as role=generic in the dev tools a11y tree if the element contains text nodes:

	<!-- these appear in the a11y tree -->
	<span>this is a span</span>
	<div>this is a div</div>

	<!-- these don't appear in the a11y tree -->
	<span> </span>
	<div> </div>
HTML-AAM Chrome 120 FF 120 Safari 17
span role=generic StaticText no role text leaf role=AXStaticText
div role=generic StaticText role=generic role=generic role=AXStaticText

dd8 avatar Dec 14 '23 18:12 dd8