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

TreeView: Improve accessibility of async items #2429

Merged
merged 18 commits into from Oct 14, 2022
Merged

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Oct 12, 2022

Addressing a11y feedback from https://github.com/github/primer/issues/815#issuecomment-1273922579

👉 Try it out

Changes

  • Announce to screen readers when a subtree is done loading using an aria-live region (based on @ericwbailey's guidance)
  • Add a state prop to TreeView.SubTree to support the aria-live region implementation
  • Properly move focus from the loading item to the first child item when loading is finished
CleanShot.2022-10-12.at.19.21.59.mp4

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Oct 12, 2022

🦋 Changeset detected

Latest commit: b1b0766

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 12, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 77.66 KB (0%)
dist/browser.umd.js 78.34 KB (0%)

@colebemis colebemis temporarily deployed to github-pages October 12, 2022 22:35 Inactive
@colebemis colebemis temporarily deployed to github-pages October 12, 2022 23:00 Inactive
@colebemis colebemis marked this pull request as ready for review October 13, 2022 02:22
@colebemis colebemis requested review from a team and rezrah October 13, 2022 02:22
@colebemis colebemis requested review from joshblack and ericwbailey and removed request for rezrah October 13, 2022 02:28
@colebemis colebemis temporarily deployed to github-pages October 13, 2022 02:35 Inactive
@colebemis colebemis temporarily deployed to github-pages October 13, 2022 18:37 Inactive
@colebemis colebemis temporarily deployed to github-pages October 13, 2022 18:58 Inactive
@colebemis colebemis temporarily deployed to github-pages October 13, 2022 19:09 Inactive
Copy link
Member

@joshblack joshblack 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! Left some questions/comments, it was awesome to see how it reads on NVDA 🔥

src/TreeView/TreeView.tsx Outdated Show resolved Hide resolved
// Show loading indicator after a short delay
React.useEffect(() => {
if (state === 'loading') {
timeoutId.current = safeSetTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like since we're having to manually manage the timer that we could use setTimeout and clearTimeout directly. Is there something that safeSetTimeout is doing here that's nice to have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think safeSetTimeout is a thin wrapper around setTimeout to make sure all timeouts get cleaned up when a component unmounts. Not sure if there are downsides to using safeSetTimeout here instead of setTimeout directly

@colebemis colebemis temporarily deployed to github-pages October 14, 2022 04:38 Inactive
@colebemis colebemis temporarily deployed to github-pages October 14, 2022 20:52 Inactive
@colebemis colebemis temporarily deployed to github-pages October 14, 2022 21:00 Inactive
@colebemis colebemis merged commit e7802ed into main Oct 14, 2022
@colebemis colebemis deleted the treeview-async-a11y branch October 14, 2022 21:05
@primer-css primer-css mentioned this pull request Oct 14, 2022
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.

None yet

2 participants