Skip to content

Commit

Permalink
Fix broken ComparisonTable columns on screen readers (#694)
Browse files Browse the repository at this point in the history
* remove aria-hidden from ComparisonTable

* add changeset

* fix axe violation

* github-actions[bot] Regenerated snapshots

* improve changeset

* fix styles

* snapshots

---------

Co-authored-by: joshfarrant <joshfarrant@users.noreply.github.com>
  • Loading branch information
joshfarrant and joshfarrant authored Aug 16, 2024
1 parent 8265b93 commit 5f1181b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-houses-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react-brand': patch
---

Improved screen reader accuracy of column indexes in `ComparisonTable`.
10 changes: 5 additions & 5 deletions packages/react/src/ComparisonTable/ComparisonTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@
text-align: left;
}

.ComparisonTable th:first-of-type {
.ComparisonTable .ComparisonTable-cell-heading:first-child {
width: 25%;
margin-right: 40px;
}

.ComparisonTable tr td:nth-of-type(1),
.ComparisonTable tr:nth-of-type(1) th:nth-of-type(2) {
.ComparisonTable tr td:nth-of-type(1):not(.ComparisonTable-cell-heading),
.ComparisonTable tr:nth-of-type(1) .ComparisonTable-cell-heading:nth-child(2) {
width: 40%;
}
.ComparisonTable tr td:nth-of-type(2),
.ComparisonTable tr:nth-of-type(1) th:nth-of-type(3) {
.ComparisonTable tr td:nth-of-type(2):not(.ComparisonTable-cell-heading),
.ComparisonTable tr:nth-of-type(1) .ComparisonTable-cell-heading:nth-child(3) {
width: 35%;
margin-left: 40px;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/ComparisonTable/ComparisonTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export const _ComparisonTable = forwardRef(
if (rowChild.type === Cell) {
const isFeatured = rowChildIndex === featuredColumn
return React.cloneElement(rowChild, {
as: 'th',
'aria-hidden': !rowChild.props.children ? 'true' : undefined,
as: rowChild.props.children ? 'th' : 'td',
className: clsx(
styles['ComparisonTable-cell'],
styles[`ComparisonTable-cell-heading`],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5f1181b

Please sign in to comment.