DLG-002 Keep one dialog open at a time
- Level
- Rule
- Verdict
- Unanimous (2 of 2)
- Area
- Dialogs
- Status
- decided, version 1.0.2
Rule
Never open a dialog on top of another dialog. Show any further step, including a question about discarding typed input, by replacing the open dialog's content, and a failed main action as a notice inside it, or close the dialog and move the work to a page. Only a full-screen dialog may have a short confirmation or alert on top.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: The question takes the dialog's place
Notes
- Order more paper
Don't: A second dialog on top of the first
Notes
- Order more paper
Why
A dialog already takes the person away from the page and hides part of it. A second dialog on top hides even more, and the person has to keep two unfinished things in mind at once. They also have to close the layers in the right order to get back. On the web, each layer holds focus, so two layers mean two places where focus can get lost when one closes. One dialog at a time keeps the path short: in, do the task, out. No WCAG criterion forbids a second dialog. WCAG 2.2, 2.4.3 Focus Order, 2.1.2 No Keyboard Trap and 4.1.2 Name, Role, Value are all easier to meet with one layer than with two. This rule is our design choice.
Do
- A dialog Edit profile has a button Choose department that needs a long list. The list replaces the dialog's content, with a Back button that brings back the profile fields as the person left them.
- A flow to add a new user has three steps. Each step replaces the last inside the same dialog, and the dialog shows "Step 2 of 3".
- The person has typed in a dialog New note and presses Cancel. The dialog asks first, as the guideline FRM-004b describes: its content is replaced by the question "Discard this note?" with Cancel and Discard note. Discard note names the action, as DLG-003 says, and uses the danger style, as DLG-005 says. Focus starts on Cancel, as DLG-004 says. Cancel brings back the note as the person left it and puts focus on the Cancel button they pressed.
- Save in a dialog Edit customer fails because a colleague changed the same customer a minute ago. Add a notice inside the dialog, above the buttons, such as "Someone else changed this customer while you were typing. Copy what you want to keep, then reload." Keep everything the person typed.
- A form that holds a lot of typed input lives on a page, or in a full-screen dialog on a small screen.
- On a phone, the person fills in a damage report for their car in a full-screen dialog Damage report, then closes it. One short confirmation opens over it: "Discard the damage report?" with Cancel and Discard report. Cancel closes the confirmation and puts focus back on the control in the full-screen dialog that opened it.
- While that confirmation is open, the dialog beneath cannot be reached with the keyboard, the mouse or a screen reader. Only the top layer is marked as a modal dialog, and it has its own role and name. Escape does what Cancel does, so it closes only the confirmation.
- The main action succeeds. Close the dialog and show the result as a message on the page, such as "Profile saved", not as another dialog.
Don't
- Open Choose department as a second dialog on top of Edit profile.
- Open each step of a flow as a new dialog over the one before.
- Open "Discard this note?" as a second dialog on top of an ordinary dialog. Replace the dialog's content instead.
- Show "Someone else changed this customer" in an alert over an ordinary dialog.
- Show a field's error, such as "Enter a valid phone number", in a dialog over a form dialog. It belongs at the field, as FRM-002a says.
- Label the choices in a discard question Yes and No, or Keep writing in place of Cancel.
- Let a confirmation over a full-screen dialog offer a new task, such as Save as template … that opens a further dialog.
- Show two confirmations over a full-screen dialog at the same time.
Exceptions
- One short confirmation over a full-screen dialog. A full-screen dialog covers the whole screen and is meant for small screens. One short confirmation or alert about it may open on top, but only when closing it would throw away what the person entered, or when its main action failed for a reason not tied to a field, such as a clash with someone else's change. It holds no task of its own, opens nothing further, and returns focus to the full-screen dialog when it closes. Never show two at once. Field errors are never covered by this exception. A discard confirmation follows DLG-003, DLG-004 and DLG-005.
- Menus, pickers and popovers. A dropdown menu, a date picker, a tooltip or a popover that opens from a control inside a dialog is not a dialog, and this rule does not cover it.
- Non-modal panels. A side panel that leaves the page usable is not a modal dialog and is outside this rule.
- What Escape does. Escape does what Cancel does, as DLG-001 says. In a discard question that replaced the dialog's content, it brings back the content. In a confirmation over a full-screen dialog, it closes only the confirmation.
Verdict
Unanimous (2 of 2). Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 2.4.3 Focus Order |
| WCAG 2.2 | Law | Supports | 2.1.2 No Keyboard Trap |
| WCAG 2.2 | Law | Supports | 4.1.2 Name, Role, Value |
| Material Design | Judge | Supports | Dialogs: guidelines |
| Apple Human Interface Guidelines | Judge | Supports | Modality |
| Carbon Design System | Judge | No position | |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert witness | No position |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.2, : Shorter rule sentence, now three sentences. No change in what the rule asks. The discard example refers to FRM-004b.
- Version 1.0.1, : Examples in English.
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Dialogs: 5 rules and 2 guidelines · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.