w3c / html-aria

ARIA in HTML
https://w3c.github.io/html-aria/
Other
181 stars 48 forks source link

Make gridcell one of the implicit roles for td elements (if in grid) #195

Closed carmacleod closed 4 years ago

carmacleod commented 4 years ago

Reopening #60 because ARIA in HTML is now inconsistent with HTML AAM for "gridcell", and because browsers are now using implied role of "gridcell" when td is in "grid".

The HTML AAM spec says that in certain circumstances, td (and th) map to gridcell:

To see this in Chrome:

  1. APG Data Grid Example
  2. inspect one of the grid's cells in Chrome DevTools
  3. the td element in the Accessibility panel has (implicit) role "gridcell"

image

Firefox also defaults to role="gridcell" for td in grid. Did not check Safari, but Chrome + FF = 2.

So the ARIA in HTML entry for td (and th) need to say basically the same thing as HTML AAM for td and th.

Also, the tr entry seems a bit oddly worded now, given that tr in grid (and treegrid) defaults to row.

It currently says:

role=row, may be explicitly declared when child of a table element with role=grid or treegrid

but I think it only needs to say:

role=row, when child of a table element with role=grid or treegrid

I will provide a PR shortly.

scottaohara commented 4 years ago

seems to me that it needs to be updated as: TD: role=cell if a descendant of a table element. role=gridcell if a descendant of a table with role=grid or treegrid.

Since a tr is (should be) an implicit role=row when a child of table, grid, or treegrid, then seems to me it doesn't need any of those quantifiers and it should just say role=row. We should only be explicitly noting that the role may be set IF the implicit role is not properly communicated, and thus needs to have the role set to correct the gap.

th has a lot of its own conditions for what the implicit role is...
if a descendant of a table, role=columnheader, rowheader or cell (if not a header) if a descendant of grid/treegrid, role=columnheader, rowheader orgridcell

Related, the roles that May be used on an element should also probably be updated depending on the implicit role...which is a whole other todo here... e.g. if a td is a child of a role=grid, depending on the circumstance i'd submit that very well should not allow for any role to be applied to it, since that could break the expected structure of the grid. Similarly, i find it odd to allow any role on a tr if the parent table's mapping has not been overwritten by another role. Otherwise it'd be inappropriate to have something like the following, which if you take the spec at face value and don't take into consideration other markup pattern expectations, allows for right now.

<table>
  <tr role=list>
    <!-- ... -->
  </tr>
</table>
JAWS-test commented 4 years ago

th ... if a descendant of a table, role=columnheader, rowheader or cell (if not a header)

By "if no header" do you mean the scope=rowgroup/colgroup? If yes, the question would be, how this is correctly mapped, so that the information transmitted with this attribute is not lost ...

Surprisingly, the specification in HTML AAM is incomplete: No specification for ARIA mapping and incomplete specification for API mapping:

scope: ... Defines whether the element is a row or column header

scottaohara commented 4 years ago

@JAWS-test, yes scope=row or col. The mappings you linked to for scope, as well as many others currently marked as "?", are presently held up in a PR due to respec having a build error due to spec tooling changes.

Regardless, that's not a blocker here as we're already aware of what the implicit roles can be.

carmacleod commented 4 years ago

Sorry - I am just seeing the previous 2 comments. Is there something else I should add to the PR I just created in order to clarify "if not a header"? Maybe instead say:

(if scope is not specified)

Regarding the "whole other todo", I could perhaps say (for td, th, tr):

Any role applicable to the ancestor table element's implied or explicit role.

JAWS-test commented 4 years ago

@scottaohara

I wrote:

By "if no header" do you mean the scope=rowgroup/colgroup?

Your anwser:

yes scope=row or col

The question remains, how rowgroup and colgroup are meaningfully mapped

scottaohara commented 4 years ago

Thanks @JAWS-test. Misread what you were asking. Those are also mapped as row header and column header.

what i meant by my original comment is that ths could be exposed as a cell... though testing that again today with modern browsers, I'm not sure that's actually still the case... at least in how they're being mapped. how they're announced by screen readers may be another topic all together.

JAWS-test commented 4 years ago

but scope=row is something else than scope=rowgroup (and col and colgroup are similarly different). If AT only interprets both as rowheader or columnheader, I think that's wrong. The corresponding ARIA role is simply missing here, isn't it?

scottaohara commented 4 years ago

yes, they are different in what they imply. A header scoped to a row vs a rowgroup and similar for columns... but at some point the platform APIs apparently decided that the purposes were close enough separate mappings / exposed roles were not created.

All that said, this is getting off topic for the scope of the ARIA in HTML spec. If a new role needs to be created and uniquely exposed it could be brought up with the ARIA / CORE AAM specs.