Skip to content
Open
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
17 changes: 4 additions & 13 deletions src/macro-carousel/macro-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ value. Add CSS units to its value to avoid breaking the slides layout.`);
}

/**
* Updates the `aria-hidden` and `inert` attributes on the slides.
* Update accessibility attributes on slides.
* @private
*/
_updateSlidesA11y() {
Expand All @@ -1140,21 +1140,12 @@ value. Add CSS units to its value to avoid breaking the slides layout.`);
slidesInView.push((this.selected + i) % this._slides.length);
}

// Set aria-hidden to false only for the slides whose indexes are included
// in the slidesInView array.
let isSlideInView;
this._slides.map(slide => slide.element).forEach((slideEl, slideIndex) => {
isSlideInView = !isUndefined(slidesInView.find(i => i === slideIndex));
// Slides in view have `aria-hidden` set to `false`.
slideEl.setAttribute(ATTRS.STANDARD.ARIA.HIDDEN,
isSlideInView ? ATTR_VALUES.FALSE : ATTR_VALUES.TRUE);
// Slides in view don't have the `inert` attribute and can be focused.
if (isSlideInView) {
slideEl.removeAttribute(ATTRS.STANDARD.INERT);
slideEl.setAttribute(ATTRS.STANDARD.TABINDEX, -1);
} else {
slideEl.setAttribute(ATTRS.STANDARD.INERT, '');
}

// Ensure DOM is not accessible unless it is in the view.
slideEl.inert = !isSlideInView;
});
}

Expand Down