Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data grid examples should use gridcell role #1030

Open
aleventhal opened this issue May 14, 2019 · 3 comments
Open

Data grid examples should use gridcell role #1030

aleventhal opened this issue May 14, 2019 · 3 comments
Labels
Feedback Issue raised by or for collecting input from people outside APG task force

Comments

@aleventhal
Copy link

Regarding data grid examples, such as this one:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/grid/dataGrids.html#ex1_label

The descendants have been implemented without include role="gridcell". They rely on the hope that a <td tabindex="-1"> element is exposed the same way as a role="gridcell". The fact that it works is more lucky than good, and is confusing to new ARIA authors.

The ARIA spec says that a grid has required owned elements of row, which has required owned elements of gridcell.

Even if it could be argued that it's ok because HTML AAM and CORE AAM use similar mappings for the two things, I think it's probably not explicitly ARIA and therefore confusing.

@carmacleod
Copy link
Contributor

Hi @aleventhal !

I believe it's intentional. The example states:

  • Since the grid role is applied to a table element, the row , rowheader, colheader, and gridcell roles do not need to be specified because they are implied by tr, th, and td tags.

The HTML AAM and CORE AAM map tr to row, td in grid to gridcell, th as column header to columnheader, and th as row header to rowheader. So the grid example is working by design and not just by luck, because AT implemented the mappings.

That said, I see that the HTML spec (which new authors would be more familiar with) is a little fuzzy on this point... it seems to be missing the "if it's in a grid" default roles:

Also, other APG examples do tend to have more of a "divs and spans with ARIA" approach, and I can see your point that the grid example might be confusing without that.

It wouldn't be too difficult to rewrite this example using a div with display:table, div rows and span gridcells, etc.

@mcking65 What do you think? Would you prefer the "divs, spans, and ARIA" approach?
@aleventhal If Matt likes the approach, would you be happy to provide a PR? :)

@aleventhal
Copy link
Author

aleventhal commented May 14, 2019

I'm not saying that it's necessary to remove the <tr> or <td>, but using role explicitly is nice, because it teaches good ARIA coding. So, either <span role="gridcell"> or <td role="gridcell"> is what I'd probably teach someone.

@carmacleod
Copy link
Contributor

using role explicitly is nice, because it teaches good ARIA coding.

Does it? I'm not sure. There's definitely confusion around that. It used to be needed in the past, particularly for newer HTML5 elements like section elements, but I think it mostly shouldn't be needed today.

The W3C HTML spec for each element says:

Allowed ARIA role attribute values:
some role (default - do not set)

The ARIA in HTML spec says:

Web developers SHOULD NOT set the ARIA role and aria-* attributes to values that match the implicit ARIA semantics defined in the table.

Steve F's 2015 On HTML belts and ARIA braces article is still mostly relevant (although today's browsers and AT don't need roles on section elements any more).

Anyhow, I submitted a PR to the W3C HTML spec to fix up the fuzziness. Hopefully that will help clarify.

(The WHATWG spec seems to just point to the HTML-AAM in one place, as far as I can tell, and none of its elements seem to explicitly mention their default role or supported aria attributes. This may be the source of some of the confusion, because if new aria authors are coming from the WHATWG spec, then they have had very little exposure to ARIA before trying to use it).

@charmarkk charmarkk added the Feedback Issue raised by or for collecting input from people outside APG task force label May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feedback Issue raised by or for collecting input from people outside APG task force
Projects
None yet
Development

No branches or pull requests

3 participants