Skip to content

Commit 444e6f5

Browse files
committed
hotfix(a11y): fix for aria-hidden not applying to slides properly
1 parent d35e1e7 commit 444e6f5

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/macro-carousel/macro-carousel.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,15 +1145,15 @@ value. Add CSS units to its value to avoid breaking the slides layout.`);
11451145
let isSlideInView;
11461146
this._slides.map(slide => slide.element).forEach((slideEl, slideIndex) => {
11471147
isSlideInView = !isUndefined(slidesInView.find(i => i === slideIndex));
1148-
// Slides in view have `aria-hidden` set to `false`.
1148+
1149+
// Ensure DOM is not accessible unless it is in the view.
1150+
slideEl.inert = !isSlideInView;
11491151
slideEl.setAttribute(ATTRS.STANDARD.ARIA.HIDDEN,
11501152
isSlideInView ? ATTR_VALUES.FALSE : ATTR_VALUES.TRUE);
1153+
11511154
// Slides in view don't have the `inert` attribute and can be focused.
11521155
if (isSlideInView) {
1153-
slideEl.removeAttribute(ATTRS.STANDARD.INERT);
1154-
slideEl.setAttribute(ATTRS.STANDARD.TABINDEX, -1);
1155-
} else {
1156-
slideEl.setAttribute(ATTRS.STANDARD.INERT, '');
1156+
slideEl.setAttribute(ATTRS.STANDARD.TABINDEX, '-1');
11571157
}
11581158
});
11591159
}

0 commit comments

Comments
 (0)