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
Conversation
Tachometer resultsChrometable permalinkbasic-test
Firefoxtable permalinkbasic-test
|
Lighthouse scores
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 Transfer Size
Request Count
|
|
||
// 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}`); |
There was a problem hiding this comment.
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?
45ea969
to
74cd78e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @blaabaer 🙇🏼
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?
sp-table
elementaria-rowcount
value is correct.sp-table
elementaria-rowcount
value is correct.Screenshots (if appropriate)
Before my changes
After my changes
Types of changes
Checklist
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
.