Comparison
Focus managementvsFocus trap
Focus management
you opened the dialog and moved focus into it, then put focus back on the button when it closed.
Deliberately moving keyboard focus so it follows what just happened, and restoring it when the interaction ends. Every overlay, route change and dynamically inserted region needs it, because otherwise focus stays where it was and a keyboard user is somewhere the page is no longer showing. Losing focus to the document body is the specific failure, and it drops the user back at the top of the page.
Full entry →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 →