Skip to content

FRM-004a Ask before a full-screen dialog throws away unsaved changes, and only when something would be lost

Level
Rule
Verdict
Unanimous (2 of 2)
Area
Forms
Status
decided, version 1.0.4

Rule

When closing a full-screen dialog would throw away changes the person has not saved, ask first, whichever way they close it, with Cancel to keep everything and a button that names the discard; when nothing would be lost, close at once.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: Ask once before the review is lost

Cancel and the close icon ask before the review is lost

Open the dialog, type a few words and press Cancel, the close icon or Escape. The same question opens each time, with focus on its own Cancel, which keeps every word. Open it again and close it without typing: it closes at once.

Don't: Close at once and lose the text

Cancel and the close icon close at once

Cancel, the close icon and Escape close the dialog straight away. A person who pressed the icon by mistake, or meant to go back to the page for a moment, loses everything they wrote.

Why

A full-screen dialog, one that covers the whole screen and is used on small screens, is where people do longer work, and it is easy to leave by accident. A thumb slips onto the close icon, or a swipe meant for something else takes the person back. If that throws away ten minutes of typing without a word, the loss is real and may not be noticed until later. One short question at that moment gives the work a second chance. The question only helps if it is rare. A product that asks every time, also when nothing was typed, teaches people to tap straight through it, and then it protects nothing. That is why closing at once when nothing would be lost matters as much as the question, and why saving as people go is better still. No WCAG criterion requires this question. WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data) asks for a safeguard before stored data is changed or deleted; unsaved input is not stored data, but this rule gives the same kind of safeguard for a loss that is just as hard to undo. The question must be exposed with a role and a name, so a screen reader user knows the view did not simply close, which supports 4.1.2 Name, Role, Value.

Do

  • On a phone, the person writes a review of a hotel stay in a full-screen dialog Write a review, then presses the close icon. One short confirmation opens on top: "Discard this review?" with two buttons, Cancel and Discard review. Over a full-screen dialog, this one confirmation may sit on top, as DLG-002 says. It opens nothing further.
  • Ask on every way of closing that would throw the changes away. That is always Cancel. It is also the close icon, Escape, a swipe that dismisses the view and the browser back button, if it closes the view, whenever those throw the changes away too. Send every way out that discards through the same code, so none can skip the question.
  • Cancel in the question means "do not leave". It closes the confirmation, keeps every word of the review, and puts focus back where it was in the full-screen dialog.
  • An action that keeps the work and then closes never asks. If the close icon keeps the review as a draft and says so, it closes at once. Keeping a draft happens this way, or by saving as the person goes, never as a third button in the confirmation.
  • When the close icon keeps a draft and Cancel discards, give the close icon an accessible name that says so, such as "Save draft and close". Escape, a swipe and the browser back button do what the close icon does: they keep the draft and close at once. Only Cancel leads to "Discard this review?". Escape still matches a visible way out, as DLG-001 asks.
  • Focus starts on Cancel when the confirmation opens, as DLG-004 says. Discard review is never the default, so a stray Enter changes nothing. Escape inside the confirmation does what Cancel does, as DLG-001 says.
  • Give Discard review the danger style and a label that names what is lost, as DLG-003 and DLG-005 say.
  • Mark only the confirmation as the modal layer while it is open, with the question as its name, so a screen reader announces it and the review beneath cannot be reached.
  • Count a change only when a value differs from what the view started with. Typing a word and deleting it again is no change. A value the product filled in by default is not a change by the person, but a value the browser or a password manager filled in at the person's request is.
  • The person opens Write a review, reads the hotel's questions, types nothing and closes it. It closes at once.
  • A full-screen Packing list saves each item as it is ticked or typed and shows "Saved". Closing it never asks, because nothing is at risk. Prefer this wherever the product can do it.
  • The close icon tries to keep the review as a draft and the save fails. Keep the review open with everything kept, and do not close. Show the problem at the field if it belongs to one, as FRM-002a says, or as a notice inside the dialog if it does not, as DLG-002 says.
  • What Cancel must do in the form itself is covered by FRM-003.

Don't

  • Close Write a review at once on the close icon after the person has typed three paragraphs.
  • Ask on Cancel but let a swipe or the browser back button close the view with no question.
  • Ask "Discard this review?" when the person opened the dialog and typed nothing.
  • Show the question when the close icon keeps the review as a draft, since nothing would be lost.
  • Add a third button to the confirmation, such as Save as draft. Keep a draft by saving as the person goes or through the close icon instead.
  • Label the choices Yes and No, or put Keep writing in place of Cancel.
  • Start focus on Discard review, or let Enter press it before the person has moved there.
  • Let Publish review close the view without publishing when the review cannot be sent, so the person believes it went out. The main action does its job or keeps the view open and says why.
  • Stack a second confirmation on top of the first.

Exceptions

  • Full-screen dialogs only. Dialogs and sheets that do not fill the screen are covered by the guideline FRM-004b. Leaving a page with unsaved changes is the guideline FRM-004c, and keeping the work on a page form the guideline FRM-004d.
  • While sending. Once the person has pressed the main action and the view shows progress, such as "Publishing …", the input is on its way. STA-005a covers what closing does then. Its own choice is that no discard question is asked during the wait.

Verdict

Unanimous (2 of 2). Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on FRM-004a
SourceRoleStancePage
WCAG 2.2LawSupports3.3.4 Error Prevention (Legal, Financial, Data)
WCAG 2.2LawSupports4.1.2 Name, Role, Value
Material DesignJudge SupportsDialogs: guidelines
Apple Human Interface GuidelinesJudge SupportsModality
Alerts
Carbon Design SystemJudge No position
GOV.UK Design SystemExpert witness No position
Nielsen Norman GroupExpert witness SupportsCancel vs Close: Design to Distinguish the Difference, by Aurora Harley
Confirmation Dialogs Can Prevent User Errors, by Jakob Nielsen
Modal & Nonmodal Dialogs: When (& When Not) to Use Them, by Therese Fessenden

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.4, : Refers to FRM-004c and FRM-004d for pages.
  • Version 1.0.3, : Refers to FRM-004b for dialogs and sheets that do not fill the screen and to STA-005a for the time while sending.
  • Version 1.0.2, : Title says that the question comes only when something would be lost.
  • Version 1.0.1, : Examples in English.
  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Forms: 15 rules and 12 guidelines · All rules