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

Fix broken ComparisonTable columns on screen readers #694

Merged
merged 7 commits into from
Aug 16, 2024

Conversation

joshfarrant
Copy link
Contributor

@joshfarrant joshfarrant commented Aug 14, 2024

Summary

Removed the aria-hidden attribute from empty <th> cells which was causing table structure to be misrepresented by screen readers

List of notable changes:

  • Removed aria-hidden from ComparisonTable column headers

What should reviewers focus on?

  • Ensure the table structure is accurately represented when using a screen reader

Steps to test:

  1. Open a ComparisonTable example on Storybook.
  2. Enable a screen reader (eg VoiceOver).
  3. Navigate through the table and ensure that column numbers and titles are accurately communicated.

Supporting resources (related issues, external links, etc):

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • New visual snapshots have been generated / updated for any UI changes
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Videos

Note the mis-reported column numbers in the first video.

Before After
ComparisonTable-before.mp4
ComparisonTable-after.mp4

Copy link

changeset-bot bot commented Aug 14, 2024

🦋 Changeset detected

Latest commit: 7c6faac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@primer/react-brand Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Aug 14, 2024

🟢 No design token changes found

Copy link
Contributor

github-actions bot commented Aug 14, 2024

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@joshfarrant joshfarrant force-pushed the joshfarrant/a11y-3753 branch from 3f00da5 to ac54a41 Compare August 14, 2024 08:46
@joshfarrant joshfarrant marked this pull request as ready for review August 14, 2024 08:49
@@ -55,8 +55,7 @@ export const _ComparisonTable = forwardRef(
children: React.Children.map(child.props.children, (rowChild, rowChildIndex) => {
if (rowChild.type === Cell) {
return React.cloneElement(rowChild, {
as: 'th',
'aria-hidden': !rowChild.props.children ? 'true' : undefined,
as: rowChild.props.children ? 'th' : 'td',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the conditional behaviour needed here? Wouldn't it always be a th for the first row?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Column alignment is also off for the first row... not sure if related to this or the removal of aria-hidden

before
Screenshot 2024-08-15 at 17 35 45

after
Screenshot 2024-08-15 at 17 35 52

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I should have added context on the th/td behaviour here (and checked the snapshots after making the change!).

I added this as axe was complaining about empty th cells. You can see the rule here

https://dequeuniversity.com/rules/axe/4.7/empty-table-header?application=axeAPI

I couldn't find a recommended approach for this kind of 2-way table where the top-left cell doesn't have any meaning, hence why I landed on the td approach.

Thanks for spotting the CSS issues. Fixing the CSS might take a bit of extra work as there are a lot of selectors which expect that first cell to be a th.

Let me dig into this a bit more and find an approach that works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the suggestion from Tetralogical I've opted to keep this as a <td> and have fixed the style issues

Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to https://github.com/primer/brand/pull/694/files#r1718673566. You can see the column misalignment in this diff 👇

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't for life of me figure out what's changed here 😄 ... any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No me neither — I've had this a few times recently, I don't know if it's related to me running the snapshots locally vs using the label

Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth removing these changes, or fixing it in a follow. up. FWIW I usually trust my local machine to regen vs Actions...

Copy link
Collaborator

@rezrah rezrah left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for fixing this @joshfarrant

@joshfarrant joshfarrant merged commit 5f1181b into main Aug 16, 2024
18 checks passed
@joshfarrant joshfarrant deleted the joshfarrant/a11y-3753 branch August 16, 2024 14:52
@primer-css primer-css mentioned this pull request Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants