Skip to content

Commit

Permalink
Don't use aria-disabled for buttons (#2077)
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Jun 14, 2023
1 parent 532095e commit fe578c1
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-hairs-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Don't use aria-disabled for buttons
5 changes: 0 additions & 5 deletions app/components/primer/beta/base_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ def initialize(

@system_arguments[:tag] = :button
@system_arguments[:disabled] = ""
@system_arguments[:aria] = merge_aria(
@system_arguments, {
aria: { disabled: true }
}
)
end

def call
Expand Down
6 changes: 6 additions & 0 deletions previews/primer/beta/base_button_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def playground(tag: :button, block: false, type: :button, disabled: false)
def default(tag: :button, block: false, type: :button)
render(Primer::Beta::BaseButton.new(tag: tag, block: block, type: type)) { "Button" }
end

# @label Disabled
#
def disabled
render(Primer::Beta::BaseButton.new(disabled: true)) { "Button" }
end
end
end
end
2 changes: 1 addition & 1 deletion test/components/alpha/button_marketing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def test_renders_with_the_css_class_variant_mapping_to_the_provided_variant
def test_forces_button_tag_when_disabled
render_inline(Primer::Alpha::ButtonMarketing.new(tag: :a, disabled: true)) { "content" }

assert_selector("button.btn-mktg[disabled][aria-disabled=true]")
assert_selector("button.btn-mktg[disabled]")
end
end
2 changes: 1 addition & 1 deletion test/components/alpha/hellip_button_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ def test_does_not_render_content
def test_disabled
render_inline(Primer::Alpha::HellipButton.new(aria: { label: "Custom aria label" }, disabled: true))

assert_selector("button[disabled][aria-disabled=true]", text: "…")
assert_selector("button[disabled]", text: "…")
end
end
2 changes: 1 addition & 1 deletion test/components/beta/close_button_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ def test_can_override_aria_label
def test_disabled
render_inline(Primer::Beta::CloseButton.new(aria: { label: "Label" }, disabled: true))

assert_selector("button.close-button[disabled][aria-disabled=true]")
assert_selector("button.close-button[disabled]")
end
end
2 changes: 1 addition & 1 deletion test/components/beta/details_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_disabled
end

refute_selector("details")
assert_selector("button[disabled][aria-disabled=true]", text: "Summary")
assert_selector("button[disabled]", text: "Summary")
end

def test_status
Expand Down
2 changes: 1 addition & 1 deletion test/components/primer/beta/icon_button_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def test_aria_label_is_set_when_tooltips_are_hidden

def test_forces_button_tag_when_disabled
render_inline(Primer::Beta::IconButton.new(icon: :star, "aria-label": "Star", disabled: true, tag: :a))
assert_selector(".Button-withTooltip button[disabled][aria-disabled=true]")
assert_selector(".Button-withTooltip button[disabled]")
end
end

0 comments on commit fe578c1

Please sign in to comment.