File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
app/components/primer/beta
test/components/primer/beta Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @primer/view-components " : patch
3
+ ---
4
+
5
+ Add parenthesis to trailing counter for React parity, and to improve screen reader speech output
Original file line number Diff line number Diff line change 8
8
< span class ="Button-label "> <%= trimmed_content %> </ span >
9
9
<% if trailing_visual %>
10
10
< span class ="Button-visual Button-trailingVisual ">
11
- <%= trailing_visual %>
11
+ <% if @trailing_visual_counter %>
12
+ < span class ="sr-only "> (<%= trailing_visual %> )</ span >
13
+ <%= trailing_visual %>
14
+ <% else %>
15
+ <%= trailing_visual %>
16
+ <% end %>
12
17
</ span >
13
18
<% end %>
14
19
</ span >
Original file line number Diff line number Diff line change @@ -68,7 +68,10 @@ class Button < Primer::Component
68
68
renders_one :trailing_visual , types : {
69
69
icon : Primer ::Beta ::Octicon ,
70
70
label : Primer ::Beta ::Label ,
71
- counter : Primer ::Beta ::Counter
71
+ counter : lambda { |**system_arguments |
72
+ @trailing_visual_counter = true
73
+ Primer ::Beta ::Counter . new ( "aria-hidden" : true , **system_arguments )
74
+ }
72
75
}
73
76
74
77
# Trailing action appears to the right of the trailing visual.
Original file line number Diff line number Diff line change @@ -27,6 +27,18 @@ def test_renders_with_leading_visual_icon
27
27
assert_selector ( ".Button .Button-leadingVisual .octicon-alert" )
28
28
end
29
29
30
+ def test_renders_with_trailing_visual_counter
31
+ render_inline ( Primer ::Beta ::Button . new ) do |component |
32
+ component . with_trailing_visual_counter ( count : 15 )
33
+ "Button"
34
+ end
35
+
36
+ assert_selector ( ".Button" , text : "Button" )
37
+ assert_selector ( '[aria-hidden="true"]' , text : "15" )
38
+ # Parenthesis provides improved screen reader output
39
+ assert_selector ( ".sr-only" , text : "(15)" )
40
+ end
41
+
30
42
def test_renders_with_leading_visual_svg
31
43
render_inline ( Primer ::Beta ::Button . new ) do |component |
32
44
component . with_leading_visual_svg do
You can’t perform that action at this time.
0 commit comments