Skip to content

Commit

Permalink
Make content outside of Modal inert
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Feb 19, 2025
1 parent c856964 commit ca91955
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/components/src/modal/aria-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function modalize( modalElement?: HTMLDivElement ) {
}

if ( elementShouldBeHidden( element ) ) {
element.setAttribute( 'aria-hidden', 'true' );
element.setAttribute( 'inert', '' );
hiddenElements.push( element );
}
}
Expand All @@ -49,6 +49,7 @@ export function elementShouldBeHidden( element: Element ) {
element.tagName === 'SCRIPT' ||
element.hasAttribute( 'hidden' ) ||
element.hasAttribute( 'aria-hidden' ) ||
element.hasAttribute( 'inert' ) ||
element.hasAttribute( 'aria-live' ) ||
( role && LIVE_REGION_ARIA_ROLES.has( role ) )
);
Expand All @@ -64,6 +65,6 @@ export function unmodalize() {
}

for ( const element of hiddenElements ) {
element.removeAttribute( 'aria-hidden' );
element.removeAttribute( 'inert' );
}
}

0 comments on commit ca91955

Please sign in to comment.