Skip to content

[#70190] Add missing accessibility semantics for Border Box Table#21523

Merged
myabc merged 8 commits intorelease/17.0from
bug/70190-border-box-table-missing-roles-aria-attributes
Jan 8, 2026
Merged

[#70190] Add missing accessibility semantics for Border Box Table#21523
myabc merged 8 commits intorelease/17.0from
bug/70190-border-box-table-missing-roles-aria-attributes

Conversation

@myabc
Copy link
Contributor

@myabc myabc commented Dec 28, 2025

Ticket

https://community.openproject.org/work_packages/70190

What are you trying to accomplish?

Provide proper accessibility semantics for the Border Box Table component to make it easier for users of Assistive Technologies (AT) to navigate through and interpret data in Border Box Tables.

It address the following issues:

  • BorderBoxTables lack proper table semantics, so screen readers interpret them as generic lists rather than tables.
  • Column headers are not recognized correctly and are often read as a single block of text.
  • Rows are announced as list items and may be read in full instead of cell by cell.
  • Cells are not associated with their column headers, removing important contextual information for screen reader users.
  • Action or button columns may have their headers skipped or announced as “blank,” making their purpose unclear.

This PR also fixes our use of BEM syntax.

Screenshots

See ticket for screenshots and notes to help review this PR.

Screenshot 2025-12-30 at 15 32 47

What approach did you choose and why?

This PR has an upstream prerequisite: primer/view_components#3821

This PR uses its own BorderBox implementation to allow additional customisation. In particular, in order to adhere to Best Practices, we need to avoid applying certain roles (such as rowgroup) to list elements. See inline comment for more details.

Long term, we may want to discuss whether this is still the right strategy. Even though ARIA roles are provided to allow table semantics on on table elements, they are not recommended - the prevailing advice on accessibility is to always prefer native HTML elements.

Merge checklist

@myabc myabc marked this pull request as ready for review December 28, 2025 04:12
Copilot AI review requested due to automatic review settings December 28, 2025 04:12
@myabc myabc changed the base branch from dev to release/17.0 December 28, 2025 04:12
@myabc myabc added styling ruby Pull requests that update Ruby code bugfix DO NOT MERGE labels Dec 28, 2025
@myabc myabc added this to the 17.0.x milestone Dec 28, 2025
@myabc myabc changed the title [#70190] Add A11y semantics for Border Box Table [#70190] Add missing accessibility semantics for Border Box Table Dec 28, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive ARIA semantics to the Border Box Table component to improve accessibility for screen readers and other assistive technologies. The changes include adding semantic roles (table, rowgroup, row, columnheader, rowheader, cell) and ARIA attributes (colcount, colindex, colspan) to properly structure the table for accessibility. Additionally, the CSS class naming convention has been updated from BEM modifier syntax (--) to BEM element syntax (__) to better reflect the semantic structure.

Key changes:

  • Added ARIA table semantics (role="table", role="rowgroup", role="row", etc.)
  • Updated CSS class names from modifier to element syntax (e.g., op-border-box-grid--headingop-border-box-grid__header)
  • Added comprehensive test coverage for accessibility features
  • Refactored component templates to support proper ARIA structure

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
spec/support/shared/components/border_box_table_component.rb Updated shared examples to use new CSS class names with __ element syntax
spec/support/pages/groups.rb Updated page object selectors to use new __row-item class name
spec/components/op_primer/border_box_table_component_spec.rb Added comprehensive test coverage for ARIA roles and attributes (table, rowgroup, row, columnheader, cell, etc.)
app/components/op_primer/border_box_table_component.sass Refactored CSS to use BEM element syntax (__) instead of modifier syntax (--) for better semantic clarity
app/components/op_primer/border_box_table_component.rb Added column_count method and updated header class logic to support ARIA structure
app/components/op_primer/border_box_table_component.html.erb Added ARIA roles and attributes to table container, headers, rows, and cells; restructured template to properly nest semantic elements
app/components/op_primer/border_box_row_component.rb Added cell_role method to determine rowheader vs cell roles; refactored cell_classes method using class_names helper
app/components/op_primer/border_box_row_component.html.erb Added ARIA roles to cells and actions; removed wrapper div to flatten structure for better ARIA compliance

@myabc myabc force-pushed the bug/70190-border-box-table-missing-roles-aria-attributes branch 8 times, most recently from e08c233 to 4cc833b Compare December 29, 2025 14:51
Comment on lines 32 to 40
# A patched version of Primer's BorderBox that allows overriding the `tag:`
# for rows, as well as additional label arguments.
#
# @note
# DO NOT use this component unless you have a good reason to do so.
# This component will be removed once primer/view_component#3821 is merged
#
# @see https://github.com/primer/view_components/pull/3821
# @api private
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also comment over here:

primer/view_components#3821 (comment)

@myabc myabc force-pushed the bug/70190-border-box-table-missing-roles-aria-attributes branch 2 times, most recently from 3e52f16 to 0bcaac6 Compare December 31, 2025 00:23
Add WAI-ARIA roles and relevant attributes to ensure Border Box tables
have table-like semantics. This commit makes changes to the structure of
the rendered markup to comply with the strict structure needed for ARIA
tables.

This commit also fixes BEM usage and removes some useless overrides.

https://community.openproject.org/work_packages/70190
Makes methods that should be public public.
@myabc myabc force-pushed the bug/70190-border-box-table-missing-roles-aria-attributes branch from 0bcaac6 to f0371d1 Compare December 31, 2025 16:53
@HDinger HDinger requested a review from bsatarnejad January 5, 2026 09:50
Copy link
Contributor

@bsatarnejad bsatarnejad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @myabc
Thanks for fixing it!
It works almost good, but I find sth confusing for the AT user, for example here:

Image

In the header, NVDA reads:
Title column 1 title, date and time column 2 date and time,....

It repeats the column name.

@myabc
Copy link
Contributor Author

myabc commented Jan 6, 2026

@bsatarnejad I think that is actually the default NVDA behaviour (which I find weird). Can you compare behavior with a normal/native HTML table?

@bsatarnejad
Copy link
Contributor

bsatarnejad commented Jan 6, 2026

@bsatarnejad I think that is actually the default NVDA behaviour (which I find weird). Can you compare behavior with a normal/native HTML table?

I tested a native html, it reads out like: column 1 value.
In a row (not header), all cell data is read correctly except the first cell. In my example it reads:
future meeting row 2 title column 1 link future meeting.
Project column 3 demo project.

@myabc myabc requested a review from bsatarnejad January 7, 2026 12:09
@myabc myabc merged commit fd04f0d into release/17.0 Jan 8, 2026
16 of 18 checks passed
@myabc myabc deleted the bug/70190-border-box-table-missing-roles-aria-attributes branch January 8, 2026 17:19
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

2 participants