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

Add parenthesis to trailing counter #2807

Merged
merged 5 commits into from
Apr 30, 2024
Merged

Add parenthesis to trailing counter #2807

merged 5 commits into from
Apr 30, 2024

Conversation

khiga8
Copy link
Contributor

@khiga8 khiga8 commented Apr 26, 2024

What are you trying to accomplish?

This PR adds an sr-only parenthesis to improve screen reader output on the trailing counter. This update makes this have more parity with the React button. I followed the markup used there for consistency.

It is worth noting that if this button content is dynamically updated (e.g because the counter is incremented), the change will not be announced to screen reader users without additional markup changes. I'm still investigating a recommendation for this separately - https://github.com/github/accessibility/pull/6222.

Integration

This should not be a breaking change.

List the issues that this change affects.

Fixes: https://github.com/github/primer/issues/2208

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.

What approach did you choose and why?

I conditionally rendered the parenthesis with an sr-only span.

Anything you want to highlight for special attention from reviewers?

No

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 Apr 26, 2024

🦋 Changeset detected

Latest commit: 307f7c7

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

@@ -68,7 +68,10 @@ class Button < Primer::Component
renders_one :trailing_visual, types: {
icon: Primer::Beta::Octicon,
label: Primer::Beta::Label,
counter: Primer::Beta::Counter
counter: lambda { |**system_arguments|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pls lmk if there is a better way to know that the trailing_visual is a counter, without setting this boolean.

Copy link
Contributor

⚠️ Visual differences found

Our visual comparison tests found UI differences. Please review the differences by viewing the files changed tab to ensure that the changes were intentional.

Review visual differences

Comment on lines 12 to 13
<span class="sr-only">(<%= trailing_visual %>)</span>
<span aria-hidden="true"><%= trailing_visual %></span>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is this causing a shift 🤔

Screenshot of visual counter a few pixels down because of this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I'm seeing in my browser does not match the changes in the snapshots. Does anyone know why I might not be seeing what's reflected in the snapshots?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok actually nvm I see it now.

Having the counter nested inside another <span> seems to be the issue. Looks like I might want to directly set the aria-hidden on the counter.

@khiga8 khiga8 marked this pull request as ready for review April 26, 2024 16:59
@khiga8 khiga8 requested review from a team as code owners April 26, 2024 16:59
counter: Primer::Beta::Counter
counter: lambda { |**system_arguments|
@trailing_visual_counter = true
Primer::Beta::Counter.new("aria-hidden": true, **system_arguments)
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 am directly setting aria-hidden on the counter, because when I nested this inside a span, it caused issues. See #2807 (comment)

Copy link
Contributor

@lindseywild lindseywild left a comment

Choose a reason for hiding this comment

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

Looks good from an accessibility perspective :)

@khiga8
Copy link
Contributor Author

khiga8 commented Apr 30, 2024

Thank you! Please merge whenever because I don't have permissions!

@camertron camertron merged commit 1863522 into main Apr 30, 2024
29 checks passed
@camertron camertron deleted the kh-add-paranthesis branch April 30, 2024 16:44
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.

4 participants