Skip to content

Commit

Permalink
Fix aria-hidden bug
Browse files Browse the repository at this point in the history
Apply flex so nested span is centered

Temp
  • Loading branch information
khiga8 committed Jan 16, 2025
1 parent 4ba32a5 commit 6741547
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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>
<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
10 changes: 10 additions & 0 deletions test/playwright/beta/button.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {test, expect} from '@playwright/test'

test.describe('Button', () => {
test('With trailing counter', async ({page}) => {
await page.goto(`/rails/view_components/beta/button/trailing_counter`)
const component = await page.locator('#component-preview')

expect(component.getByRole('button', {name: 'Star (15)'}))
})
})

0 comments on commit 6741547

Please sign in to comment.