File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -639,13 +639,26 @@ export const dismiss = async <OverlayDismissOptions>(
639639 return false ;
640640 }
641641
642- const lastOverlay = doc !== undefined && getPresentedOverlays ( doc ) . length === 1 ;
642+ /**
643+ * For accessibility, toasts lack focus traps and don’t receive
644+ * `aria-hidden` on the root element when presented.
645+ *
646+ * All other overlays use focus traps to keep keyboard focus
647+ * within the overlay, setting `aria-hidden` on the root element
648+ * to enhance accessibility.
649+ *
650+ * Therefore, we must remove `aria-hidden` from the root element
651+ * when the last non-toast overlay is dismissed.
652+ */
653+ const overlaysNotToast = doc !== undefined ? getPresentedOverlays ( doc ) . filter ( ( o ) => o . tagName !== 'ION-TOAST' ) : [ ] ;
654+
655+ const lastOverlayNotToast = overlaysNotToast . length === 1 && overlaysNotToast [ 0 ] . id === overlay . el . id ;
643656
644657 /**
645- * If this is the last visible overlay then
646- * we want to re-add the root to the accessibility tree.
658+ * If this is the last visible overlay that is not a toast
659+ * then we want to re-add the root to the accessibility tree.
647660 */
648- if ( lastOverlay ) {
661+ if ( lastOverlayNotToast ) {
649662 setRootAriaHidden ( false ) ;
650663 document . body . classList . remove ( BACKDROP_NO_SCROLL ) ;
651664 }
You can’t perform that action at this time.
0 commit comments