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(table): Add aria-rowcount to virtualized tables #4156

Merged
merged 4 commits into from Mar 20, 2024

Conversation

blaabaer
Copy link
Contributor

@blaabaer blaabaer commented Mar 7, 2024

Description

The sp-table component can be virtualized, which only renders table rows that are currently visible in the viewport, which helps with performance on large tables. However, this can trip up screenreaders, which only detect and announce the rendered rows, and not the true size of the table. aria-rowcount is a screenreader attribute which announces the true unvirtualized size of the table.

This PR implements the automatic application of aria-rowcount for virtualized tables.

Related issue(s)

Motivation and context

Accuracy and efficacy of screenreader accessibility.

How has this been tested?

  • Run storybook - Table > Virtualized > [Any of these]
    1. Inspect the sp-table element
    2. Observe that the aria-rowcount value is correct.
  • Visit docs site - Table > Virtualized
    1. Inspect the sp-table element
    2. Observe that the aria-rowcount value is correct.

Screenshots (if appropriate)

image image

Before my changes
image

After my changes
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

github-actions bot commented Mar 7, 2024

Tachometer results

Chrome

table permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 530 kB 262.20ms - 266.39ms - unsure 🔍
-1% - +1%
-2.49ms - +3.11ms
branch 497 kB 262.12ms - 265.84ms unsure 🔍
-1% - +1%
-3.11ms - +2.49ms
-
Firefox

table permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 530 kB 406.19ms - 417.09ms - unsure 🔍
-2% - +2%
-9.34ms - +6.22ms
branch 497 kB 407.65ms - 418.75ms unsure 🔍
-2% - +2%
-6.22ms - +9.34ms
-

@blaabaer blaabaer marked this pull request as ready for review March 11, 2024 19:15
Copy link

github-actions bot commented Mar 11, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.93 0.98 0.97
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 229.604 kB 217.331 kB 🏆 228.775 kB
Scripts 61.651 kB 54.479 kB 🏆 54.617 kB
Stylesheet 35.343 kB 30.949 kB 🏆 42.264 kB
Document 5.898 kB 5.191 kB 5.182 kB 🏆
Third Party 126.712 kB 126.712 kB 126.712 kB

Request Count

Category Latest Main Branch
Total 43 43 43
Scripts 35 35 35
Stylesheet 5 5 5
Document 1 1 1
Third Party 2 2 2


// Ensures screenreaders can announce the true size of the table
// despite virtualization only rendering a subset of rows.
this.setAttribute('aria-rowcount', `${this.items.length}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because this code path is only run when items has a length were this table to be used with filtering or searching and the length could conceivable become 0, there is a change that this data would be out of date. Should we remove this attribute in the implied else at line 474?

@Westbrook Westbrook force-pushed the davidx/table-rowcount-tomain branch from 45ea969 to 74cd78e Compare March 20, 2024 21:58
Copy link
Collaborator

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @blaabaer 🙇🏼

@Westbrook Westbrook merged commit b4136ab into main Mar 20, 2024
50 checks passed
@Westbrook Westbrook deleted the davidx/table-rowcount-tomain branch March 20, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug][a11y]: Virtualized Table should include aria-rowcount attribute
2 participants