From 1d14474e1d149684f180ef33ae35511fc0dd157a Mon Sep 17 00:00:00 2001 From: Kris Date: Fri, 15 Sep 2023 11:27:02 -0400 Subject: [PATCH] A11Y: "more" nav link should use aria-expanded (#23613) --- .../app/components/sidebar/more-section-links.hbs | 1 + .../sidebar-user-community-section-test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/more-section-links.hbs b/app/assets/javascripts/discourse/app/components/sidebar/more-section-links.hbs index 519dbd483a3..51219441b82 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/more-section-links.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/more-section-links.hbs @@ -8,6 +8,7 @@ @action={{this.toggleSectionLinks}} @label="sidebar.more" class="btn-flat sidebar-more-section-links-details-summary" + aria-expanded={{if this.open "true" "false"}} /> diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js index cab4af31383..a793ef8148c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js @@ -60,6 +60,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "additional section links are displayed" ); + assert.ok( + exists( + ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary[aria-expanded='true']" + ), + "aria-expanded toggles to true when additional links are displayed" + ); + await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); @@ -83,6 +90,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ), "additional section links are hidden when clicking outside" ); + + assert.ok( + exists( + ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary[aria-expanded='false']" + ), + "aria-expanded toggles to false when additional links are hidden" + ); }); test("clicking on everything link", async function (assert) {