# Focus management on open and close

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

Area: Dialogs and overlays. Evidence behind the answer: Moderate. Last checked November 12, 2026.
Page: https://uxreference.com/dialogs/focus-management

## The answer

Move focus into a dialog when it opens, and back to the control that opened it when it closes.

- **Moderate.** When a modal dialog opens, move focus into it. (https://uxreference.com/dialogs/focus-management#rule-4)
- **Moderate.** When an overlay closes, return focus to the control that opened it. (https://uxreference.com/dialogs/focus-management#rule-5)

## The problem

When an overlay opens or closes, keyboard and screen reader users are wherever focus is, and if focus is left behind or lost they are stranded.

## How to decide

None. The rules apply together. The one open choice, first focus, is [rule 7](https://uxreference.com/dialogs/focus-management#rule-7).

## Every rule

Each rule has a grade: Settled (required by WCAG AA or law, or replicated research), Strong, Moderate, Weak, or Unsettled (use the stated default until the evidence settles).

#### Rule 1. Settled, WCAG AA

If focus can move into a component by keyboard, it must be possible to move out by keyboard alone.

- Applies when: Any component that takes focus.
- Based on: Standard or law
- Principle: Work for everyone

Why: WCAG 2.2 success criterion 2.1.2, level A.

Sources: [Understanding SC 2.1.2: No Keyboard Trap](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html)

Link: https://uxreference.com/dialogs/focus-management#rule-1

#### Rule 2. Settled, WCAG AA

Content that opens must take its place in the focus order where it makes sense, so the next key press reaches it.

- Applies when: Content is added or revealed after an action.
- Based on: Standard or law
- Principle: Work for everyone

Why: WCAG 2.2 success criterion 2.4.3 Focus Order, level A. The criterion page gives dialogs as examples: a non-modal dialog joins the order right after its trigger, and a modal dialog takes focus, keeps the page behind out of reach, and hands focus back to the trigger or the element after it on dismissal.

Sources: [Understanding SC 2.4.3: Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html)

Link: https://uxreference.com/dialogs/focus-management#rule-2

#### Rule 3. Settled, WCAG AA

The focused control must not be entirely hidden by content you place over it, such as sticky bars or an overlay that does not take focus.

- Applies when: Fixed or overlaid content shares the screen with focusable controls.
- Based on: Standard or law
- Principle: Work for everyone

Why: WCAG 2.2 success criterion 2.4.11 Focus Not Obscured (Minimum), level AA.

Sources: [Understanding SC 2.4.11: Focus Not Obscured (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html)

Link: https://uxreference.com/dialogs/focus-management#rule-3

#### Rule 4. Moderate

When a modal dialog opens, move focus into it.

- Applies when: A modal dialog opens.
- Based on: Standard or law
- Principle: Work for everyone

Why: HTML standard behavior and APG (non-binding) agree, and the WCAG 2.4.3 page describes the same behavior in an example, which is informative and sets no floor.

Sources: [HTML Standard: the dialog element](https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element); [apg-2026-dialog-modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/); [carbon-2025-modal-danger](https://carbondesignsystem.com/components/modal/usage/)

Link: https://uxreference.com/dialogs/focus-management#rule-4

#### Rule 5. Moderate

When an overlay closes, return focus to the control that opened it.

- Applies when: An overlay opened from a control closes.
- Based on: Standard or law
- Principle: Work for everyone

Why: APG and the HTML standard's dialog behavior agree. Primer notes the builder must wire it. No user study of focus return was found.

Sources: [apg-2026-dialog-modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/); [HTML Standard: the dialog element](https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element); [Dialog (GitHub Primer React component)](https://primer.style/product/components/dialog/)

Link: https://uxreference.com/dialogs/focus-management#rule-5

#### Rule 6. Weak

If the opening control no longer exists, move focus to the nearest element that fits what the person is doing next.

- Applies when: The trigger was removed, for example after deleting the item it belonged to.
- Based on: Practitioner research
- Principle: Work for everyone

Why: APG only; advisory wording.

Sources: [apg-2026-dialog-modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)

Link: https://uxreference.com/dialogs/focus-management#rule-6

#### Rule 7. Unsettled

Which element gets focus first inside a dialog is unsettled.

Until the evidence settles, use this default: Focus the first field if there is one; the start of the content if it is long; never the destructive button.

- Applies when: A dialog opens.
- Based on: Convention
- Principle: Work for everyone

Why: The HTML standard uses a marked element, else the first focusable one, else the dialog. APG says it depends: the top for long content, the least destructive control for irreversible steps. Carbon focuses the first input or the primary button.

Sources: [apg-2026-dialog-modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/); [carbon-2025-modal-danger](https://carbondesignsystem.com/components/modal/usage/); [HTML Standard: the dialog element](https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element); [Dialog (GitHub Primer React component)](https://primer.style/product/components/dialog/)

Link: https://uxreference.com/dialogs/focus-management#rule-7

## Accessibility requirements

- WCAG 2.1.2 (A), 2.4.3 (A), 2.4.11 (AA). (https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html)
- A properly built modal dialog passes 2.4.11 because it takes focus; non-modal overlays and sticky bars are where it fails. (https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html)

## Common mistakes

- Closing an overlay and leaving focus at the top of the page.
- A sticky footer that covers the control that has focus.
- Opening a dialog and leaving focus on the page behind.

## Still open

- No user study of focus return or first focus was found; every rule is based on standards and guidance.
- Where should focus go after content loads or an item is deleted in a list? APG gives one advisory sentence.

## Related problems

- [Modal dialogs](https://uxreference.com/dialogs/modal): Use a modal only when people must respond before anything else, and only after their own action.
- [Popovers](https://uxreference.com/dialogs/popovers): Open popovers on click, not hover, and close them with Escape or a click outside.
- [Drawers](https://uxreference.com/dialogs/drawers): Put a panel beside the content when people need both, and send long work to its own page.
- [Skip links](https://uxreference.com/navigation/skip-links): Give keyboard users a way past repeated blocks: a skip link first in the focus order, and a heading for each section.
- [Error summaries](https://uxreference.com/forms/error-summary): After a failed submit, list every error at the top, each linking to its field, and keep the message at each field too.

## Sources

- [Understanding SC 2.1.2: No Keyboard Trap](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html). W3C WAI, n.d., normative standard (Understanding document, informative).
- [Understanding SC 2.4.3: Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html). W3C WAI, n.d., normative standard (Understanding document, informative).
- [Understanding SC 2.4.11: Focus Not Obscured (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html). W3C WAI, n.d., normative standard (Understanding document, informative).
- [HTML Standard: the dialog element](https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element). WHATWG, n.d., normative specification (living standard).
- [apg-2026-dialog-modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/). n.d., authoring guidance, non-binding (APG is not a standard).
- [carbon-2025-modal-danger](https://carbondesignsystem.com/components/modal/usage/). n.d., component documentation.
- [Dialog (GitHub Primer React component)](https://primer.style/product/components/dialog/). GitHub Primer, n.d., component documentation.

---
From Solved Problems in UX by Athen Pellicci, an evidence-graded reference of web interface problems. CC BY 4.0. https://uxreference.com/
