Kelly Mears

Focus Management

Deliberately controlling which element receives keyboard focus as an interface changes.

Design & Interface2 min read227 words15 out · 27 in
also calledFocusReturn focus

Focus management is the deliberate control of what has keyboard focus as the interface changes. For anyone navigating by keyboard or screen reader, focus is their position in the page — losing it means losing their place entirely, usually back at the top.

The obligations are straightforward to state. Opening an overlay moves focus into it. Closing it returns focus to whatever opened it. Removing the focused element moves focus somewhere sensible rather than letting it fall to the document body. Navigating to a new view announces and focuses the new content.

Return-focus is where implementations usually break, and the cause is subtle: capturing the currently focused element on open is not enough if the opener is unmounted while the overlay is showing. The captured node is detached by the time you try to restore, and focusing a detached node silently does nothing. The fix is an explicit reference to the remounted opener rather than a captured node.

A companion bug: a return-focus effect that also fires on first mount, with nothing having been opened, steals focus on every page load. Guarding on "has actually opened once" is the fix, and the case worth testing explicitly.

Component tests can catch a lot of this, provided the test harness reproduces the real structure — a demo whose opener stays mounted will pass while the real application is broken.

See also15

Focus Trap

Confining keyboard focus inside a modal surface so it cannot wander behind it.

Design & Interface13 connections

Component Story

An isolated rendered instance of a component, usable as documentation, a workbench, and a test.

Testing & Verification17 connections

Portal

Rendering an element into a different part of the document than its logical parent.

Web Platform18 connections

Headless Component

A component supplying behavior and accessibility with no styling of its own.

Design & Interface16 connections

contenteditable

The HTML attribute that makes an element directly editable, and the surface behind most rich-text editors.

Web Platform12 connections

Keyboard Navigation

Making every interactive affordance reachable and operable without a pointer.

Design & Interface34 connections

Accessibility

Designing so that people with disabilities can use a thing, and the standards that make it checkable.

Design & Interface44 connections

Document Object Model

The live tree of objects a browser builds from a document, and the surface every UI framework writes to.

Web Platform27 connections

ARIA

Attributes that describe roles, states, and relationships to assistive technology when HTML cannot.

Design & Interface31 connections

Semantic HTML

Using elements for their meaning, so the document conveys structure without extra description.

Design & Interface24 connections

Carousel

A panel that rotates through several slides in one spot, popular on home pages as a way to give everyone's content top billing, and notorious for low engagement and accessibility problems.

Design & Interface10 connections

Tabs

A row of labels that switch between panels of content occupying the same space, borrowed from paper folder tabs, suited to parallel sections viewed one at a time, and governed by a specific keyboard pattern.

Design & Interface12 connections

Bottom Sheet

A panel that slides up from the bottom of a phone screen to show extra content or choices, often draggable between heights, placed where thumbs can reach it on large phones.

Design & Interface13 connections

Focus Indicator

The visible outline or highlight showing which element on a screen will receive keyboard input, essential for anyone who doesn't use a mouse, and for years routinely removed by designers who found it unattractive.

Design & Interface12 connections

Toast Notification

A brief, non-blocking message that slides in to confirm an action or report a background event, then disappears on its own.

Design & Interface10 connections

Linked from27