A Dialog Should Give Focus Back

Opening a dialog is only half the interaction. Keyboard users also need a clear entry point, a usable way out, and a sensible place to continue.

Brass key beside an arched doorway and a returning paper path

Follow the focus, not the animation

Open a dialog with the keyboard and watch where focus goes. If it remains on the page behind the overlay, someone may be operating controls they cannot see. Choose an initial focus target that suits the content. A short confirmation may focus a safe action; a longer explanation may need its heading or beginning announced before the controls. No single starting point is right for every dialog.

Keep the background out of the task

A modal dialog should prevent interaction with the underlying page while it is active. Use appropriate native or well-tested dialog behavior and verify the accessible name. Adding an aria attribute without implementing focus and interaction behavior does not create a modal. Test Tab and Shift+Tab through the available controls, including validation messages and newly revealed content. Nested overlays make this harder, so avoid them when a simpler flow is possible.

Make dismissal predictable

Provide a visible close or cancel control with a clear accessible name. Support Escape where the interaction allows dismissal, and avoid making a click outside the panel the only exit. Destructive actions need particular care: a cancellation should not silently commit the operation, and an accidental backdrop click should not discard a substantial unsaved form. Explain the consequence before asking someone to make that choice.

Return to the work

After closing, focus usually belongs on the control that opened the dialog. If that control no longer exists, choose the next logical place, such as the heading of the updated record. Test cancellation, successful submission, and server failure separately. A dialog that works on the happy path can still strand a keyboard user after an error. Include mobile zoom and screen-reader checks before treating the interaction as complete.

Written by Ted Chow LLC

Your next chapter

Have Something in Mind?
Let’s Make It Happen.

A new website, a better workflow, or an idea worth exploring.
We’d love to hear what you’re thinking.

Let’s talk about it