liveBook · Manning

Focus management

As explained in Architecting Accessibility

Focus management is the deliberate control of keyboard focus movement, placement, and return within an interactive interface.

A keyboard user can lose their place when focus jumps unexpectedly, follows a confusing order, or slips behind an open dialog. Focus management keeps movement predictable: put focus where the current task begins, keep it within the active interaction when needed, and return it to a useful place afterward. section 5.3.2

Start with the HTML document order. In a payment form, place “Proceed to Payment” before “Back to Search” when that is the logical task order; use CSS for visual placement. Check that the resulting Tab sequence still makes sense. Avoid positive tabindex values to force a custom order: they are difficult to maintain. section 5.3.2

When a modal dialog opens

Move focus into the dialog. A short confirmation might start at its primary action; a dialog with important introductory information might start at its heading or container. While it is open, Tab and Shift+Tab should cycle within the dialog, not reach background controls. On dismissal, return focus to the opener. If that element no longer exists, choose the next logical place instead of sending the user to the top of the page. section 5.3.2

Figure 5.8 In modal dialogs, keyboard focus should remain inside the dialog until it is dismissed, rather than moving to background content.

The diagram makes the dialog boundary concrete: keyboard focus stays inside the active dialog rather than moving to background content. section 5.3.2

Custom tabs need more than ARIA labels. Their keyboard behavior and focus movement must work too: the tab example moves focus with arrow keys and updates which tab participates in the Tab sequence. Use the WAI-ARIA Authoring Practices Guide for expected component behavior, then test with a keyboard and screen reader. Do not assume a component library has handled this correctly. section 2.5.2

How Architecting Accessibility covers it

How deep it goes
Gives procedural guidance for document order and dialog focus placement, containment, and return, with tab-handling code as a custom-component example.
Examples
Illustrates payment-form button order, focus contained within a modal dialog, and keyboard-controlled tabs.
What it assumes
Builds on HTML, CSS, and JavaScript while spelling out expected focus behavior for dialogs and custom components.
What you can do after
Practice/perform logical focus ordering and dialog focus placement, containment, and return; test custom components with a keyboard and screen reader.
How it connects
Links focus management to HTML document order, CSS layout, modal dialogs, tabbed interfaces, ARIA, and keyboard interaction.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.