Skip to content

Commit

Permalink
Improve accessibility of home page slides (#125)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
clhenrick authored Nov 27, 2023
1 parent abdd201 commit c02d197
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 156 deletions.
3 changes: 2 additions & 1 deletion app/src/components/keyboardNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 12 additions & 2 deletions app/src/components/slidesContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading

0 comments on commit c02d197

Please sign in to comment.