Machine-translated – improvements welcome. Suggest an improvement
Confirmation¶
Rueckfragen (#355, among the building blocks since #1210) is the window that asks before a step or shows a notice – instead of the browser's confirm() and alert(). The title as a question, one or two sentences on the consequences, the verb on the confirm button. It is asked from anywhere with rueckfrage() and hinweis() from web/src/rueckfrage.tsx and shown in the one component Rueckfragen, which start.tsx includes once. A danger button asks its confirmation itself.
What it is for¶
- Before something dangerous: deleting, locking, signing out, anything where saved data is lost or someone is locked out. The way there is almost always a button of the kind
gefahror a danger item in the Menu – both ask the confirmation themselves. - Before a step with consequences but no danger: “Create a new address?” – the previous address will no longer accept mail. Confirm button blue.
- When leaving with unsaved changes and on Esc in the form, the Save bar asks with a confirmation.
- As a notice with only one button (
hinweis()), where something has to be read before going on – such as an error with no other place to show it (abfangen, see Asynchronous handlers).
Don't use it for something that can be undone (removing a row before saving, taking a link out of a field), and not for “Discard” by button – that one is clearly labelled. A result belongs at the button (Result at the button), not in a notice window.
Matching patterns in the pattern catalogue: B4 · Confirmations in Ablago's own dialog, B3 · Messages say why and what to do, C14 · Kinds of buttons: fixed, the same everywhere (principle 5: filled red only at the moment of decision), D3 · Sentences that are true.
How to use it¶
| With | How it works |
|---|---|
| Mouse | The confirm button runs the step, “Cancel” closes without doing anything. If the confirmation asks for a word to type, the confirm button stays disabled until it matches. |
| Keyboard | The window holds the focus (modal). With danger the focus starts on “Cancel”, so Enter destroys nothing; otherwise on the confirm button; with a word to type in the input. Tab moves between the buttons, Esc cancels. |
| Touch | The buttons have the touch area of a button (44 × 44 px). |
Several confirmations come one after the other, never on top of each other.
What it means¶
- Filled red is the confirm button only with danger – the moment of decision (principle 5). Otherwise there is nothing filled red on any page; the smoke tests check that.
- Blue is the confirm button of a confirmation without danger.
- “Cancel” is a button with a border (kind secondary) and never does anything.
- The title is a question (“Delete note?”), the confirm button names the verb (“Delete”), never “OK” or “Yes”. The text says in one or two sentences what is different afterwards (“This can't be undone.”).
- A word to type (
bestaetigeMit) only for something very dangerous – it slows down on purpose. - With a reason (
mitGrund) asks for the reason for the deletion log when deleting (#470): a choice and optionally a short text, without personal data, because the log stays when the data is gone.
States¶
| State | How it comes about | How it looks |
|---|---|---|
| danger | gefahr: true or Knopf art="gefahr" |
confirm button filled red, focus on “Cancel” |
| without danger | rueckfrage({ titel, ja }) |
confirm button blue |
| word to type | bestaetigeMit |
input “Type “…” to confirm”, confirm button disabled until the word matches |
| with a reason for the deletion log | mitGrund on the danger button |
choice “Reason” and optional note below the text |
| just a notice | hinweis({ titel, text }) |
only one button (“Got it”) |
Accessibility¶
- A
<dialog>withrole="alertdialog"andaria-modal="true", opened withshowModal()– the page behind it is locked for keyboard and screen readers (focus trap). aria-labelledbypoints to the title,aria-describedbyto the text: screen readers read question and consequences on opening.- Esc (
cancel) cancels and counts as “Cancel”. - With danger the focus starts on the safe button, otherwise on the confirm button, with a word to type in the input; the input sits in a Field with a label.
- The danger button that triggers it carries
aria-haspopup="dialog".
Code¶
import { hinweis, rueckfrage } from '../rueckfrage';
// Confirmation without danger: true = confirmed.
if (!(await rueckfrage({ titel: t('…neue-adresse-frage'), text: t('…alte-adresse-geht-nicht-mehr'), ja: t('…erzeugen') }))) return;
// Danger outside a button (rare – usually the button art="gefahr" asks itself):
if (!(await rueckfrage({ titel: t('…alles-loeschen-frage'), ja: t('…alles-loeschen'), gefahr: true, bestaetigeMit: 'LÖSCHEN' }))) return;
// Just a notice with one button (instead of alert()):
await hinweis({ titel: t('…gespeichert'), text: t('…gilt-ab-sofort') });
Property (Rueckfrage) |
Meaning |
|---|---|
titel |
What happens? As a question: “Delete note?” |
text |
consequences in one or two sentences; text (paragraphs separated by a blank line) or own content |
ja |
confirm button with a verb: “Delete”, “Sign out” … |
nein |
safe button; default “Cancel” |
gefahr |
confirm button filled red, focus first on the safe button |
bestaetigeMit |
only for something very dangerous: this word has to be typed |
| Function | When |
|---|---|
rueckfrage(r) |
ask a confirmation; returns true when confirmed |
hinweis({ titel, text?, ok? }) |
notice with one button (default “Got it”) |
mitGrund(r, vorschlag?) |
confirmation with a reason for the deletion log (Loeschgrund.tsx); returns the reason or null. On the danger button via rueckfrage.mitGrund |
Rueckfragen |
the component that shows all confirmations – once in start.tsx |
RueckfrageVorschau |
the same confirmation standing without a window, only for the pattern page |
The functions work anywhere, also outside components. web/src/rueckfrage.tsx only holds the queue – so the component Knopf (kind danger calls the confirmation itself) doesn't depend on itself through the window.
Right and wrong¶
| Right | Wrong |
|---|---|
<Knopf art="gefahr" symbol="geloescht" rueckfrage={{ titel: 'Delete note?', ja: 'Delete' }}> |
if (confirm('Really?')) … |
| Title “Delete note?”, button “Delete” | Title “Warning”, buttons “OK” and “Cancel” |
await hinweis({ titel: 'Saved', … }) |
alert('Saved') |
| Result at the button (Result at the button) | a notice window after every save |
| “Remove” a row before saving without confirmation | a confirmation for everything that can be undone |
Files and tests¶
- Building block:
web/src/bausteine/rueckfrage/Rueckfrage.tsx(windowRueckfragen,RueckfrageVorschau), reason for the deletion log:Loeschgrund.tsx, look:.rueckfrageinweb/src/stile/bausteine.cssandRueckfrage.module.css - Queue and call:
web/src/rueckfrage.tsx(rueckfrage,hinweis) - Pattern page:
web/src/bausteine/rueckfrage/muster.tsx– section Confirmation: danger, without danger, word to type, with a reason, just a notice; plus the confirmation of the danger button in the section Button - Tests:
web/test/baustein-knopf.test.ts(danger opens the confirmation); smoke tests inweb/rauchtest/bereiche/bausteine-und-knoepfe.mjs(danger with confirmation, filled red only in a confirmation)

