Machine-translated – improvements welcome. Suggest an improvement
Areas¶
useBereiche and Bereich (#1000) build the pattern “editor on the right: jump bar + areas”: the jump bar with all areas and Expand all / Collapse all at the top, the areas to expand and collapse below it. It started with the folder type (#144) and the views (#148); since #1000, number sequences, automations, users, stamps, mailboxes and data protection requests have it too.
What it is for¶
For an editor on the right with three or more areas (Basic details, Connection, Status …). A single section to expand and collapse is an Expander; different content in the same place are Tabs. Saving is done by one Save bar for the whole editor.
Matching patterns in the pattern catalogue: C15 · Editor on the right: jump bar + sections, C1 · Three columns left · middle · right, C5 · Save via the save bar, C13 · Special cases as a collapsed group at the top.
How to use it¶
| With | How it works |
|---|---|
| Mouse | A click on the head of an area expands or collapses it. A jump in the jump bar opens its area and scrolls there. “Expand all” / “Collapse all” act on all areas. |
| Keyboard | Tab reaches the jumps and the heads of the areas; Enter or Space expand and collapse. After a jump the focus is on the head of the area, Tab then continues inside the area. An anchor in the address (…#verbindung) opens its area and jumps there. |
| Touch | Jumps and the head of an area are at least 44 px high; the bar wraps and scrolls along (On the phone). |
Behaviour¶
- New (
idisnull): everything open, nothing is remembered. - Existing: as last time on this device (
localStorage, per editor the 200 entries edited last); without memory collapsed. Editors without saving (viewing and immediate actions only, e.g. the data protection request) pass{ offen: true }and start expanded as long as the device has remembered nothing. Sections in{ immerOffen: [...] }are expanded every time the editor is shown, in addition to the remembered ones – such as the stamp preview, so every change to the basics or the appearance is visible right below. Folder types and views keep their previous storage keys (dms.typeditor.offen,dms.sichteditor.offen), all others are calleddms.<editor>editor.offen. - Anchor in the address (
…/werkbank/postfaecher/<id>#verbindung) opens its area and jumps there. - Jump bar: every jump opens its area, scrolls there and moves the focus to the head of the area (
focus({ preventScroll: true })) – with the keyboard, Tab then continues inside the area; an area with an error is red and carries “!”. On the desktop the bar stays below the page header, on the phone (up to 700 px) it scrolls along. - Fewer than three areas (
SPRUNGLEISTE_AB): neither bar nor collapsing. The areas are always open, only with their title. - Collapsed, the content stays in the document (only hidden) – inputs, results and running requests are not lost. The summary (
kurz) is then shown below the title.
On the phone¶
Jumps and the head of an area are at least 44 px high with (pointer: coarse) (On the phone); “Expand all” is a small Knopf (secondary). The bar wraps and scrolls along.
What it means¶
The arrow on the head shows whether an area is open; collapsed, a summary stands below the title, so you see what is in it without expanding. Red with “!” in the jump bar means: something went wrong in this area when saving.
Rules¶
- One save for the whole editor. At the bottom there is one
Speicherleiste(web/src/Speicherleiste.tsx) for everything that is saved. If areas with immediate actions of their own sit between or after them (small forms of their own, e.g. “Set counter”), they stand outside the form – forms must not be nested – and the bar connects to it withformular="<id>". - Immediate actions stay immediate: test, fetch, reset, sign out, lock – everything that is an action of its own and not part of the draft.
- Errors open their area. If the interface checks something itself (e.g. an unknown placeholder),
klappe(k, true)marks the area while typing. What only the server finds it names asdetails.orte(Fachfehler(422, text, { orte: ['verbindung'] }));fehlerBereichereads it,oeffne(orte)expands and jumps there. - Short, consistent area names: Basic details first, then in the order in which the entry is set up; try out, status and history at the end.
- Headings: the area carries the
h2; sections inside it useh3(className="h4"), not anotherblattor a box with the same heading. - Red means error. Areas are not coloured as a danger zone – in the editor, red means “something went wrong here when saving”. Dangerous actions are shown by the red button (
art="gefahr") and the confirmation. - References to another area (“choose one in the area Stand-in”) are a jump: a
Knopf(secondary) that callsoeffne([k], true, true).
States¶
| State | How it comes about | How it looks |
|---|---|---|
| with jump bar | three or more areas | bar with all areas and “Expand all” |
| open | klappe(k), jump, anchor |
arrow pointing down, content visible |
| collapsed | memory, click | arrow pointing right, summary below the title |
| with error | klappe(k, true) |
jump red with “!” |
| fewer than three areas | fewer than SPRUNGLEISTE_AB |
no bar and no collapsing, always open |
Accessibility¶
The head of an area is a button with aria-expanded that controls its content, and carries the heading h2. A jump moves the focus to this head (focus({ preventScroll: true })), so keyboard and screen reader continue there. The jump bar is a navigation (nav) with a name (leiste(fehler, beschriftung)). An area with an error is not only red in the jump bar but carries “!” with a name for screen readers (“with error”). Collapsed content stays in the document but is hidden and not read out.
Code¶
Using it¶
import { Bereich, fehlerBereiche, useBereiche, type BereichListe } from '../bausteine';
type PfBereich = 'grunddaten' | 'verbindung' | 'abholen' | 'stand';
const liste: BereichListe<PfBereich> = [['grunddaten', t('…grunddaten')], ['verbindung', t('…verbindung')], …];
const b = useBereiche(liste, 'postfach', neu ? null : id);
const hatFehler = (k: PfBereich) => fehlerOrte.has(k);
<div className="editorform">
<Kopf … />
{b.leiste(hatFehler, t('…bereiche-des-postfachs'))}
<form id="pf-formular" className="editorform" onSubmit={…} onKeyDown={ent.tasten}>
<Bereich id="grunddaten" titel={t('…grunddaten')} klappe={b.klappe('grunddaten', hatFehler('grunddaten'))} kurz={e.name}>
…
</Bereich>
…
</form>
<Bereich id="stand" titel={t('…stand')} klappe={b.klappe('stand')}>…immediate actions…</Bereich>
<Speicherleiste ent={ent} gegenstand={t('…postfach')} formular="pf-formular" />
</div>
| Part | What for |
|---|---|
useBereiche(liste, editor, id, optionen?) |
state: auf, klappe(k, fehler?), oeffne(ks, springen?, fokus?), leiste(fehler?, beschriftung?), merke(neueId), mitLeiste; optionen.offen for editors without saving, optionen.immerOffen for sections expanded every time |
Bereich |
id (also the anchor), titel, klappe; plus hilfe (help symbol after the title), kurz (summary when collapsed), beschreibung (sentence above the content), className |
fehlerBereiche(fehler, liste, ersatz) |
areas of an error on saving: details.orte of the server's response, known ones only; otherwise ersatz |
liesOffen, merkeOffen |
the memory directly, e.g. for tests |
Files and tests¶
- Building block:
web/src/bausteine/bereiche/Bereiche.tsx, look:Bereiche.module.css - Pattern page:
web/src/bausteine/bereiche/muster.tsx– section Areas: with jump bar (one area with an error), collapsed with a summary and with fewer than three areas - Test:
web/test/baustein-bereiche.test.ts

