question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Datatable: add accessibility to table header

See original GitHub issue

Hello,

For accessibility purpose (WCAG2.1 rule 1.3.1), the HTML tables should have a not empty th tags to make the column headers visible for screen reader.

PrimeFaces generates nicely the th but there is an exception. If a column contains only technical stuff (s.t. icons), its headerText could be empty. In that case, the following code is generated by <p:column> with PrimeFaces 7.0 :

<th id="myForm:table:j_idt102" class="ui-state-default" role="columnheader" scope="col">
        <span class="ui-column-title"></span>
</th>

As said previously, the th can’t be empty. So when the headerText/f:facet header is blank, is it possible for PrimeFaces to generate a td instead of the th (only for that column) ?

Please note that this solution is also the one suggested by WAVE :

If the table cell is a header, provide text within the cell that describes the column or row. If the cell is not a header or must remain empty (such as the top-left cell in a data table), make the cell a td rather than a th.

An alternative solution exists : the developer can provide an accessibility-only title to the column such that <span class="hidden">Action icons column</span>. Personally I think that the choice between both solutions should be let to the developer because the second one is not always adapted.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Rawi01commented, Jun 24, 2019

I had a similar problem last week. According to our accessibility test we should use td instead of th for our “Toggle filters” button that toggles out filter row. This row should also use td for all cells.

I created a custom renderer that supports rendering a single column and a full row as td. I can provide a pull request as soon as I have some time to refactor my stuff.

0reactions
mellowarecommented, Apr 13, 2019

Looking at the code this is a much more difficult change than hoped.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Accessible Data Tables for Screen Reader Users
Simple Data Tables​​ Column headers are inside <th scope="col"> elements. Row headers are inside <th scope="row"> elements. Avoid using blank header cells.  ......
Read more >
Tables Tutorial | Web Accessibility Initiative (WAI) - W3C
Data tables are used to organize data with a logical relationship in grids. Accessible tables need HTML markup that indicates header cells and...
Read more >
Creating Accessible Tables - Data Tables - WebAIM
A critical step toward creating an accessible data table is to designate row and/or column headers. In the markup, the <td> element is...
Read more >
Accessibility: setting aria-label different to columns.title
Hi, I need help w/ my column-title in the aria-label to be different than it's visual-innerHTMLText: Definition: A DataTable-result: A I ...
Read more >
How can data tables be made accessible? | DO-IT
For complex tables, each table header must be marked up with a unique "id" attribute (e.g., <th id="column1a">. Then, each cell in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found