Back to React Spectrum

@react-aria/aria-modal-polyfill

packages/@react-aria/aria-modal-polyfill/README.md

2022-12-16800 B
Original Source

@react-aria/aria-modal-polyfill

This package is part of react-spectrum. Certain browser + screen reader combinations do not implement aria-modal correctly, allowing users to navigate outside of the modal. This package watches a container for aria-modal nodes and hides the rest of the dom from screen readers when one is open use the aria-hidden package.

How to use

Include this once in your application at the top level before modals are rendered.

import {watchModals} from '@react-aria/aria-modal-polyfill';
watchModals();

You can also pass it a selector string, by default it will watch body, which is where most applications should have their provider.

watchModals('.my-modal-root');