w3c / html-aam

HTML Accessibility API Mappings - new spec updates should be made in https://github.com/w3c/aria/tree/main/html-aam
https://w3c.github.io/html-aam/
Other
100 stars 27 forks source link

Clarification on <th> contextual mapping #523

Open rahimabdi opened 8 months ago

rahimabdi commented 8 months ago

I would propose adding some additional guidance on how <th> should be mapped that takes into account whether <th> is a child of <thead> (computes as role="columnheader") or <tbody> (computes as role="rowheader").

I'm unable to identify where this is explicitly stated in the HTML spec or ARIA in HTML.

Current <th> mappings in html-aam:

Relevant <th> role test in wpt/html-aam/table-roles.html and its results: https://wpt.fyi/results/html-aam/table-roles.html?label=experimental&label=master&aligned

cookiecrook commented 8 months ago

In addition to or instead of the el-th-in-row test, I think we should split that into a few more:

cookiecrook commented 8 months ago

Meant to add that label to the related WPT issue, not this one.

cookiecrook commented 8 months ago

WG update... @scottaohara FYI... We'll agenda+ once the other tests are written...

JAWS-test commented 8 months ago

I would propose adding some additional guidance on how th should be mapped that takes into account whether th is a child of thead (computes as role="columnheader") or tbody (computes as role="rowheader").

I would advise against this because it would destroy many tables in terms of accessibility. Many tables use th in the tbody in auto state for column headers. This is defined in the HTML spec. Your suggestion would turn the column headers into row headers and the tables would no longer work

rahimabdi commented 8 months ago

I would advise against this because it would destroy many tables in terms of accessibility. Many tables use th in the tbody in auto state for column headers. This is defined in the HTML spec. Your suggestion would turn the column headers into row headers and the tables would no longer work

Hello @JAWS-test!

If I'm understanding correctly, although <thead> should be where table columns are defined (excluding complex tables), authors still use <th> as descendants of <tbody> and would expect a default mapping of columnheader unless explicitly overridden via scope.

To clarify, I raised this issue to provide clarity on <th> mappings in various contexts from my observations in writing WPT tests and how browsers currently behave; from the display: contents WPT test, I'm observing that <th> in a <tbody> context maps to rowheader in several browsers despite the default auto value of scope. This may be a bug per your reasoning but I think guidance somewhere (if not in HTML spec) would be valuable.

As @cookiecrook noted above, additional testing would reveal how browsers currently treat <th> to provide more consistent cross-browser behavior expectations and non-ambiguity of table header mappings in general.

JAWS-test commented 8 months ago

authors still use as descendants of and would expect a default mapping of columnheader unless explicitly overridden via scope.

Partly correct. The HTML specification states:

A header cell anchored at the slot with coordinate (x, y) with width width and height height is said to be a column header if any of the following are true: ... the cell's scope attribute is in the auto state, and there are no data cells in any of the cells covering slots with y-coordinates y .. y+height-1.

and

A header cell anchored at the slot with coordinate (x, y) with width width and height height is said to be a row header if any of the following are true: ... the cell's scope attribute is in the auto state, the cell is not a column header, and there are no data cells in any of the cells covering slots with x-coordinates x .. x+width-1.

This seems to me to be a sufficient definition and no deviating definitions should be made. If you don't like this definition, you should open a ticket at whatwg. And if the browsers deviate from this, they are faulty and this should be reported to them so that they can correct the error