From c02d1971337d9c7a45971557c1d79f8eff392af6 Mon Sep 17 00:00:00 2001
From: Chris Henrick <161748+clhenrick@users.noreply.github.com>
Date: Mon, 27 Nov 2023 14:56:00 -0800
Subject: [PATCH] Improve accessibility of home page slides (#125)
* set attr inert to true for all non-active slides
to remove non-viewable items from the tab index
* set focus on active slide when updating
* set attr aria-hidden to true on inactive slides:
to hide their content from screen reader users
* made slides section elements with accessible names
- made slides container a main element
* set active slide aria-hidden to false...
rather than remove the attribute (is this better for assistive tech?)
* updated dep caniuse-lite
* adjust html to utilize carousel pattern from wai apg:
see: https://www.w3.org/WAI/ARIA/apg/patterns/carousel/:wq
* fixed slides keyboard navigation (in dev env)
* added missing alt text to images
* updated slide 8 h4s to be h3s
* added code comments
* cleaned up logic for setting of active slide
* fixed code comment
---
app/src/components/keyboardNavigation.js | 3 +-
app/src/components/slidesContainer.js | 14 +-
app/src/hbs_templates/main.hbs | 377 ++++++++++++++---------
app/src/scss/_columns.scss | 6 +-
app/src/scss/_slides.scss | 2 +-
app/yarn.lock | 6 +-
6 files changed, 252 insertions(+), 156 deletions(-)
diff --git a/app/src/components/keyboardNavigation.js b/app/src/components/keyboardNavigation.js
index 99915387..75367c51 100644
--- a/app/src/components/keyboardNavigation.js
+++ b/app/src/components/keyboardNavigation.js
@@ -35,7 +35,8 @@ export class KeyboardNavigation extends Component {
if (
event.target &&
typeof event.target.matches === "function" &&
- !event.target.matches("body")
+ // disregard the event when the target is NOT coming from a .slide div element
+ !event.target.matches("div.slide")
) {
return;
}
diff --git a/app/src/components/slidesContainer.js b/app/src/components/slidesContainer.js
index 118bdd8e..248973e5 100644
--- a/app/src/components/slidesContainer.js
+++ b/app/src/components/slidesContainer.js
@@ -55,8 +55,18 @@ export class SlidesContainer extends Component {
}
set activeSlide(value) {
- this.slides.forEach((slide) => slide.classList.remove("active"));
- this.slides[value].classList.add("active");
+ this.slides.forEach((slide) => {
+ if (slide === this.slides[value]) {
+ slide.classList.add("active");
+ slide.removeAttribute("inert");
+ slide.setAttribute("aria-hidden", false);
+ slide.focus();
+ } else {
+ slide.classList.remove("active");
+ slide.setAttribute("inert", true);
+ slide.setAttribute("aria-hidden", true);
+ }
+ });
}
get activeSlide() {
diff --git a/app/src/hbs_templates/main.hbs b/app/src/hbs_templates/main.hbs
index a0a9cc4e..4a6cd101 100644
--- a/app/src/hbs_templates/main.hbs
+++ b/app/src/hbs_templates/main.hbs
@@ -1,7 +1,7 @@
{{>navigation}}
-
+
{{mobile_msg}}
@@ -12,173 +12,262 @@
{{>progress_indicator}}
-
-
-
-
- {{! LanguageToggle mobile / tablet only }}
- {{>language_toggle}}
+
+ {{!-- NOTE: aria-live is used here so that when the next slide becomes active the assistive tech (e.g. screen reader) notifies the user of the change --}}
+
+
+
+ {{! LanguageToggle mobile / tablet only }}
+ {{>language_toggle}}
+