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

Ensure counter content is exposed to screen reader users #3270

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-parrots-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fake-scope/fake-pkg": patch
---

Ensure counter content is exposed to screen reader users
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- button "Button"
- button "Button"
- button "Button"
- button "Button ( )": Button ()
- button "Button ( )": Button ()
- button "Button ( )": Button ()
- button "Button ( 15 )"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🎉

- button "Button ( 15 )"
- button "Button ( 15 )"
- button "Button with tooltip"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- button "Star ( )": Star ()
- button "Star ( 15 )"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- button "Comment ( )": Comment ()
- button "Comment ( 15 )"
2 changes: 1 addition & 1 deletion app/components/primer/beta/button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<% if trailing_visual %>
<span class="Button-visual Button-trailingVisual">
<% if @trailing_visual_counter %>
<span class="d-flex" aria-hidden="true"><%= trailing_visual %></span>
Copy link
Contributor Author

@khiga8 khiga8 Jan 16, 2025

Choose a reason for hiding this comment

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

Setting flex on this newly added span to ensure content remains centered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No visual regression - good sign!

<span class="sr-only">(<%= trailing_visual %>)</span>
<%= trailing_visual %>
<% else %>
<%= trailing_visual %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/components/primer/beta/button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Button < Primer::Component
label: Primer::Beta::Label,
counter: lambda { |**system_arguments|
@trailing_visual_counter = true
Primer::Beta::Counter.new("aria-hidden": true, **system_arguments)
Primer::Beta::Counter.new(**system_arguments)
}
}

Expand Down
Loading