w3c / core-aam

Core Accessibility API Mappings
https://w3c.github.io/core-aam/
39 stars 10 forks source link

Consider calling out what nodes should be ignored for PosInSet/SetSize calculations #143

Open sivakusayan opened 2 years ago

sivakusayan commented 2 years ago

Currently, the Group Position section says that to compute aria-posinset and aria-setsize, user agents should:

...process the parent (DOM parent or parent defined by aria-owns), counting items that have the same role.

Practically, it seems that browsers use a little bit more nuance in determining what the "parent" of the set should be. For example, here is where Chromium decides to ignore certain nodes for these calculations. This makes it so if we have <divs> wrapping things like a radio button for some reason, we can still report the correct PosInSet and SetSize:

<!--Thanks to browser nuance, the radio buttons below
won't all report that they are the first radio button
in their set. -->
<div>
     <!-- PosInSet: 1 -->
    <input type="radio" value="1">1</input>
</div>
<div>
     <!-- PosInSet: 2 -->
     <input type="radio" value="2">2</input>
 </div>
 <div>
     <!-- PosInSet: 3 -->
     <input type="radio" value="3">3</input>
 </div>
 <div>
     <!-- PosInSet: 4 -->
     <input type="radio" value="4">4</input>
 </div>

However, it seems like browsers have slightly different behaviors in determining what nodes to ignore and not ignore. Unless I'm missing something, I think the spec should call out what roles should be ignored so we don't get interoperability bugs like this one, where it seems like table rows/cells are ignored as parents in Firefox but considered parents in Chromium.

JAWS-test commented 2 years ago

@sivakusayan Please note that in your example, this specification is not responsible for determining which HTML radio buttons belong to the group and what position they have within the group, because this is governed solely by the HTML specification. The rules for ARIA radio buttons differ from this, because e.g. in ARIA the membership to the group is not regulated by the name attribute.

sivakusayan commented 2 years ago

@JAWS-test Thanks for the correction, I'm still trying to make heads or tails of how the different specifications interact with each other 🙂

Thinking about this a little more, I'm guessing that the rules for this will need to differ depending on what child elements we are counting. For example, if we are counting ARIA radio buttons, we'll need to consider if there is a radiogroup ancestor. But we don't care about radiogroups if we are counting something like tabs.

JAWS-test commented 2 years ago

I think the rules for counting actually depend on whether I'm using HTML or ARIA. Whether the ARIA rules are sufficiently accurate and useful, I can't judge. I think that with ARIA elements, the parent elements always play a role as well:

etc.