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

Convey Spinner to assistive technologies #4140

Merged
merged 16 commits into from
Jun 17, 2024
Merged

Convey Spinner to assistive technologies #4140

merged 16 commits into from
Jun 17, 2024

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented Jan 10, 2024

Closes #3942

Changelog

New

  • Spinner accepts srText prop (default value is "Loading"

Changed

  • Deprecated aria-label on Spinner
  • Restricts Spinner to only accept specified props, not just any HTML attribute

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

When we ship the next major release, we can remove aria-label from Spinner and provide a codemod to change it to srText.

Testing & Reviewing

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • [unsure] Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge
  • (GitHub staff only) Integration tests pass at github/github (Learn more about how to run integration tests)

@mperrotti mperrotti requested review from a team and pksjce January 10, 2024 20:48
Copy link

changeset-bot bot commented Jan 10, 2024

🦋 Changeset detected

Latest commit: 7c736b8

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 Minor

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

@mperrotti mperrotti marked this pull request as draft January 10, 2024 20:49
Copy link
Contributor

github-actions bot commented Jan 10, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 89.72 KB (+0.1% 🔺)
packages/react/dist/browser.umd.js 89.92 KB (+0.03% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-4140 January 10, 2024 20:52 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4140 January 10, 2024 23:04 Inactive
@mperrotti mperrotti marked this pull request as ready for review January 10, 2024 23:20
@github-actions github-actions bot temporarily deployed to storybook-preview-4140 January 11, 2024 15:49 Inactive
/>
</svg>
/* inline-flex removes the extra line height */
<Box sx={{display: 'inline-flex'}} role={hasSrAnnouncement ? 'status' : undefined}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to add the role value as a prop instead of a static value? If so, we would only have two values to pick from, status and alert, with status being the default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can definitely do that. Great idea.

@github-actions github-actions bot temporarily deployed to storybook-preview-4140 January 12, 2024 19:46 Inactive
@mperrotti
Copy link
Contributor Author

I'm converting this back to a draft until we decide on a direction based on feedback in this discussion: https://github.com/github/primer/discussions/2976

@mperrotti mperrotti marked this pull request as draft January 16, 2024 16:04
@mperrotti
Copy link
Contributor Author

The aria-live issues should be resolved by #4174

@TylerJDev
Copy link
Contributor

Hey @mperrotti 👋! With live-region-element being available, do you think this PR is good to go?

@lindseywild
Copy link
Contributor

@mperrotti Hi! Just wanted to check in on the status of this PR 🙏🏻

@mperrotti
Copy link
Contributor Author

Sorry @lindseywild - this PR got lost and stale. Going to update today.

Related PVC PR: primer/view_components#2884

@mperrotti
Copy link
Contributor Author

@lindseywild @TylerJDev @joshblack - should I remove the announcements and follow @owenniblock's PVC implementation until we've figured out how to handle multiple announcements?

Comment from the PVC PR:

I would not feel comfortable if the Spinner announced by default, I think that's too risky given the number of Spinners we have in the wild already

Thread in the ADR PR

@TylerJDev
Copy link
Contributor

should I remove the announcements and follow @owenniblock's PVC implementation until we've figured out how to handle multiple announcements?

I think that's fair. Unless we can make it opt-in, where the live region only exists if the consumer turns it on themselves via a prop. Even without the live region, this PR will fix the accessibility issue on there being no context by default on the <Spinner> component.

Copy link
Contributor

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

Left some comments, but this looks good even if we remove the live region!

/>
</svg>
/* inline-flex removes the extra line height */
<Box sx={{display: 'inline-flex'}} role={hasSrAnnouncement ? 'status' : undefined}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're using the <Status> component now, we can remove the role here.

</svg>
{hasSrAnnouncement ? (
<VisuallyHidden>
<Status>{srText || ariaLabel}</Status>
Copy link
Contributor

Choose a reason for hiding this comment

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

Per #4140 (comment), we could make this opt-in and keep the live region, but I'll leave this up to you! It would probably involve an additional prop to toggle the live region being on/off with the default being off. We could also remove it and come back to it in the future, but there might be value in having it in now as opt-in.

@mperrotti
Copy link
Contributor Author

@TylerJDev - after talking to @joshblack, I decided to remove the announcement until we land on a solution for using Status in components without accidentally triggering too many announcements.

@mperrotti mperrotti enabled auto-merge June 17, 2024 18:42
@github-actions github-actions bot temporarily deployed to storybook-preview-4140 June 17, 2024 18:44 Inactive
@mperrotti mperrotti added this pull request to the merge queue Jun 17, 2024
Merged via the queue into main with commit c093411 Jun 17, 2024
30 checks passed
@mperrotti mperrotti deleted the mp/spinner-a11y branch June 17, 2024 19:11
@primer primer bot mentioned this pull request Jun 17, 2024
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.

Spinner is inaccessible by default
3 participants