act-rules / act-rules.github.io

Accessibility conformance testing rules for HTML
https://act-rules.github.io/
Other
136 stars 68 forks source link

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

Open dd8 opened 1 year ago

dd8 commented 1 year ago

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

Jym77 commented 1 year ago

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

sboptum commented 1 year ago

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.

WilcoFiers commented 1 year ago

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?

dd8 commented 9 months ago

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