Comparison
Focus trapvsinert
Focus trap
tabbing inside the modal cycles through its controls and never reaches the page behind it.
Confining keyboard focus to a subtree while a modal interaction is open, cycling from the last element back to the first. It is required for a modal dialog, because focus reaching the obscured page behind is disorienting and unrecoverable. A trap without an escape route is worse than none, which is why a modal must always close on Escape.
Full entry →inert
you marked the background inert while the dialog was open and it stopped taking focus or clicks entirely.
An attribute making a subtree unfocusable, unclickable and invisible to assistive technology in one step. It is the platform's answer to the modal problem that focus traps and `aria-hidden` used to solve in pieces, and it is far harder to get wrong. Native `dialog` opened as a modal applies it automatically to everything behind, which is a good reason to use the element.
Full entry →