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

Fix accessibility bug of missing accessible name on Dialog #2210

Merged
merged 7 commits into from
Aug 17, 2023
Merged
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
7 changes: 7 additions & 0 deletions .changeset/rich-donkeys-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@primer/view-components": minor
---

Fix accessibility bug of missing accessible name on `Primer::Alpha::Dialog`

<!-- Changed components: Primer::Alpha::Dialog -->
3 changes: 2 additions & 1 deletion app/components/primer/alpha/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def initialize(
@system_arguments, {
aria: {
disabled: true,
describedby: "#{@id}-title #{@id}-description"
labelledby: "#{@id}-title",
describedby: "#{@id}-description"
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion test/components/primer/alpha/dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_renders_title_and_subtitle_with_describedby
component.with_body { "content" }
end

assert_selector("modal-dialog[id='my-dialog'][aria-describedby='my-dialog-title my-dialog-description']") do
assert_selector("modal-dialog[id='my-dialog'][aria-labelledby='my-dialog-title'][aria-describedby='my-dialog-description']") do
assert_selector("h1[id='my-dialog-title']", text: "Title")
assert_selector("h2[id='my-dialog-description']", text: "Subtitle")
end
Expand Down
24 changes: 24 additions & 0 deletions test/system/alpha/dialog_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require "system/test_case"

module Alpha
class IntegrationDialogTest < System::TestCase
def test_modal_has_accessible_name
visit_preview(:default)

click_button("Show Dialog")

assert_selector("modal-dialog[aria-labelledby]")
assert_equal(find("modal-dialog")["aria-labelledby"], find("h1")["id"])
end

def test_focuses_close_button
visit_preview(:default)

click_button("Show Dialog")

assert_equal page.evaluate_script("document.activeElement")["aria-label"], "Close"
end
end
end
Loading