alphagov / tech-docs-gem

Gem to distribute the tech docs project
https://tdt-documentation.london.cloudapps.digital/
MIT License
15 stars 38 forks source link

Implement row level table headings to allow accessible tables with row headings #214

Closed richardTowers closed 3 years ago

richardTowers commented 3 years ago

Sometimes, tables have row-level headings as well as column level headings.

To be accessible, these need to be marked up as <th> tags. Otherwise users of screen readers and other assistive technology may not be able to work out that they're table headings rather than ordinary table cells.

⚠️ Don't forget to update the gem version in the version file and CHANGELOG before merging! ⚠️

36degrees commented 3 years ago

Looking at https://github.com/vmg/redcarpet/commit/27dfb2a738a23aadd286ac9e7ecd61c4545d29de, I'm not sure it actually helps with table row headers – I think it just makes it possible to know whether a given cell is a column header within the context of the table_cell method if you're writing your own renderer?

richardTowers commented 3 years ago

Yeah, the problem is if I implement a custom table_cell callback, all the column headers come out as <td>s - there's not enough information in the callback to work out what's a header and what's a cell.

So I could use it to implement row headers, but we'd lose column headers (which work at the moment).

36degrees commented 3 years ago

Ah! I totally mis-interpreted your comment. I was interpreting it as though that commit would bring native row headers to redcarpet, meaning we don't have to do anything at all – rather than that it would allow us to instead use the table_cell callback which would be less hacky.

Makes sense now 👍🏻

richardTowers commented 3 years ago

Yep, sorry - I should clarify the comment :)

richardTowers commented 3 years ago

Updated to clarify the comment, and to use table_row instead of table, which is a little bit more specific. Test still passes by the looks of it.

AlanGabbianelli commented 3 years ago

I see you split the test while I was still writing my comment 😄 Nice