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

When hiding a Spinner, also hide its screen reader text #3021

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

camertron
Copy link
Contributor

What are you trying to accomplish?

Unfortunately I merged #3011 a little too fast. This is a follow-up PR that adjusts the approach taken in the original PR by hiding/showing the entire Spinner, including the screen reader text.

Integration

No changes necessary in production.

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

This doesn't fix an axe scan violation, but it does address the following accessibility issue: https://github.com/github/primer/issues/3690

Merge checklist

  • Added/updated tests
    - [ ] Added/updated documentation
    - [ ] Added/updated previews (Lookbook)
  • 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.

Copy link

changeset-bot bot commented Aug 20, 2024

🦋 Changeset detected

Latest commit: 42596f3

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

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

<% end %>
<% if no_aria_label? %>
<span class="spinner-screenreader-text sr-only"><%= @sr_text %></span>
<%= render(Primer::BaseComponent.new(tag: :span, hidden: @hidden, data: { target: @target })) do %>
Copy link
Contributor

Choose a reason for hiding this comment

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

aaah, I'm guessing the Primer::BaseComponent.new() is the magic bit I needed to be able to access the screenreader-only element from other spinner files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sort of, we just needed to wrap both the <svg> and the <span class="sr-only"> in another <span> so we could hide them both together. It was a little tricky because usually we pass **system_arguments to the top-level element (eg. the new <span>), but that would break the existing API which puts **system_arguments on the <svg> element. I had to extract only certain attributes, eg. data-target and hidden, to be able to put them on the new <span> and pass everything else down to the <svg>.

@camertron camertron merged commit 8a16336 into main Aug 22, 2024
37 checks passed
@camertron camertron deleted the hide_spinner_and_sr_only_text branch August 22, 2024 16:38
@primer primer bot mentioned this pull request Aug 22, 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