@@ -29,9 +29,10 @@ export const useSlideFocusManagement = ({ isSlideDisplayed, slideRef }: UseSlide
29
29
* Display given slide to screen readers and, if focus was blocked, restore focus on elements.
30
30
*/
31
31
const enableSlide = ( ) => {
32
- // Hide from screen readers
32
+ element . removeAttribute ( 'inert' ) ;
33
33
element . setAttribute ( 'aria-hidden' , 'false' ) ;
34
34
// Find elements we have blocked focus on
35
+ // (won't be necessary once "inert" gets sufficient browser support)
35
36
element . querySelectorAll ( `.${ BLOCKED_FOCUS_CLASSNAME } ` ) . forEach ( ( focusableElement ) => {
36
37
focusableElement . removeAttribute ( 'tabindex' ) ;
37
38
focusableElement . classList . remove ( BLOCKED_FOCUS_CLASSNAME ) ;
@@ -42,6 +43,7 @@ export const useSlideFocusManagement = ({ isSlideDisplayed, slideRef }: UseSlide
42
43
* Hide given slide from screen readers and block focus on all focusable elements within.
43
44
*/
44
45
const blockSlide = ( ) => {
46
+ element . setAttribute ( 'inert' , '' ) ;
45
47
element . setAttribute ( 'aria-hidden' , 'true' ) ;
46
48
getFocusableElements ( element ) . forEach ( ( focusableElement ) => {
47
49
focusableElement . setAttribute ( 'tabindex' , '-1' ) ;
@@ -72,6 +74,7 @@ export const useSlideFocusManagement = ({ isSlideDisplayed, slideRef }: UseSlide
72
74
} ;
73
75
74
76
// Create an observer instance linked to the callback function
77
+ // (won't be necessary once "inert" gets sufficient browser support)
75
78
const observer = new MutationObserver ( callback ) ;
76
79
77
80
if ( element ) {
0 commit comments