Skip to content

Commit fb4145c

Browse files
committed
feat(slideshow): use inert on hidden slides
1 parent e6a6e32 commit fb4145c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- `SlideShow`: use `inert` on hidden slides (on top of `aria-hidden` and `tabindex="-1"`) for greater semantic.
13+
1014
## [3.9.3][] - 2024-10-09
1115

1216
### Fixed

packages/lumx-react/src/components/slideshow/useSlideFocusManagement.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ export const useSlideFocusManagement = ({ isSlideDisplayed, slideRef }: UseSlide
2929
* Display given slide to screen readers and, if focus was blocked, restore focus on elements.
3030
*/
3131
const enableSlide = () => {
32-
// Hide from screen readers
32+
element.removeAttribute('inert');
3333
element.setAttribute('aria-hidden', 'false');
3434
// Find elements we have blocked focus on
35+
// (won't be necessary once "inert" gets sufficient browser support)
3536
element.querySelectorAll(`.${BLOCKED_FOCUS_CLASSNAME}`).forEach((focusableElement) => {
3637
focusableElement.removeAttribute('tabindex');
3738
focusableElement.classList.remove(BLOCKED_FOCUS_CLASSNAME);
@@ -42,6 +43,7 @@ export const useSlideFocusManagement = ({ isSlideDisplayed, slideRef }: UseSlide
4243
* Hide given slide from screen readers and block focus on all focusable elements within.
4344
*/
4445
const blockSlide = () => {
46+
element.setAttribute('inert', '');
4547
element.setAttribute('aria-hidden', 'true');
4648
getFocusableElements(element).forEach((focusableElement) => {
4749
focusableElement.setAttribute('tabindex', '-1');
@@ -72,6 +74,7 @@ export const useSlideFocusManagement = ({ isSlideDisplayed, slideRef }: UseSlide
7274
};
7375

7476
// Create an observer instance linked to the callback function
77+
// (won't be necessary once "inert" gets sufficient browser support)
7578
const observer = new MutationObserver(callback);
7679

7780
if (element) {

0 commit comments

Comments
 (0)