The starter contains a working modal from Modal Dialog: a portal, role="dialog", Escape to close and focus restoration. Its focus can still escape, though. Pressing <kbd>Tab</kbd> past the last button lands on the page behind the overlay, and screen-reader users can browse the background freely.
Make it a true modal.
focus() or a click), pull it back in.<body> gets the inert attribute, so it can't be clicked, focused or reached by a screen reader's virtual cursor. Remove exactly the attributes you added when it closes. Don't remove an inert someone else set.initialFocusRef if given, otherwise the first focusable element, otherwise the dialog container.aria-modal/aria-labelledby.tabindex="-1", and not hidden.inert better than aria-hidden="true" on the background? What was the old workaround?<dialog>.showModal() do here for free?Spotted a mistake or a rights concern? Report an issue