Focus management on open and close

When a dialog opens or closes, keyboard and screen reader users can be left behind it, or lost.

A keyboard user opens and closes a dialog. When focus stays behind the dialog, Tab moves through the hidden page, and closing it drops focus at the top. When focus moves into the dialog and returns to Edit address on close, they keep their place.

The answer

Move focus into a dialog when it opens, and back to the control that opened it when it closes. As strong as the weakest rule behind it: moderate.

  • When a modal dialog opens, move focus into it.
  • When an overlay closes, return focus to the control that opened it.

The other rules

  • If keyboard focus can get into a component, it must be able to get out by keyboard alone.
  • Put newly opened content where it makes sense in the focus order, so the next key press reaches it.
  • Don’t let sticky bars or overlays completely hide the focused control.
  • If that control is gone, move focus to the nearest element that fits what people do next.
  • When a dialog opens, focus the first field, or the start of long content. Never the destructive button.

Accessibility

Open questions

  • OpenNo user study of focus return or first focus was found; every rule is based on standards and guidance.
  • OpenWhere should focus go after content loads or an item is deleted in a list? APG gives one advisory sentence.
Checked November 12, 2026

Sources