focus restoration
Returning keyboard focus to the element that opened an overlay, such as its trigger button, when the overlay closes.
In more detail
Without it focus falls to document.body and keyboard users must tab from the top of the page again. If the trigger no longer exists, focus should go to a sensible nearby element.
Related terms
- focus trap — Code that keeps keyboard focus inside a container, such as an open modal, wrapping from the last element back to the first.
- document.body — The page's <body> element as seen from JavaScript, the usual target for portals and the fallback when focus is lost.
- modal dialog — A window laid over the page that users must deal with before returning to the page beneath, with role="dialog" and aria-modal="true".
Taught in
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering
- Modal Dialogs & Alert Dialogs: Accessible Overlay Patterns — Design Systems & Component Engineering