Skip to content

fix(overlay): give every dialog one keyboard contract - #555

Merged
DeepDiver1975 merged 2 commits into
mainfrom
feat/538-overlay-contract
Oct 3, 2026
Merged

DeepDiver1975 merged 2 commits into
mainfrom
feat/538-overlay-contract

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Part of #538 (PR A of two; the inline panels and flyouts follow in PR B). Part of the v0.8 keyboard epic #545.

What changes

A new attached behaviour, b:Overlay (src/LageBuch.App.Shared/Behaviors/Overlay.cs), set on each overlay's root scrim. It implements contract 1 of #545:

Property Effect
CancelCommand Esc runs it. An open suggestion list or ComboBox still takes the first Esc.
PrimaryCommand Enter runs it, never inside multi-line text, and never when a focused button, list or ComboBox has already taken the key.
InitialFocus Where focus goes on open; the first tab stop when unset. A TextBox gets its text selected.

What it does beyond that:

  • Posted initial focus. Focus is set after layout, so it isn't dropped; this is the fix for ConfirmDialog's synchronous Focus(). It's posted at a lower priority than a view's own posted focus, so OperatorPrompt's stage-aware focus stays as it was.
  • TabNavigation="Cycle" on the root, so Tab stays inside.
  • Focus returns to the opener on close, if it's still there. It doesn't if another overlay took focus in the same breath, as when CloseIncident's confirm chains into the PDF options.
  • Modal focus. If focus leaves while the overlay is open, it comes back. Avalonia moves focus to the page behind when the focused control is disabled, which is what PdfExport's busy state did.

The six overlays and what they use:

Overlay Cancel Enter Initial focus
About Close — SCHLIESSEN
ConfirmDialog Cancel — (the focused button) ABBRECHEN
IncidentDataDialog Cancel Save Stichwort
OperatorPrompt Cancel — (per field, as before) its own code
PdfExportOptions Cancel — ("a stray Enter shouldn't export") first checkbox
TaskDialog Cancel Save AUFGABE

Their code-behind key handlers are removed.

One behaviour change to confirm: ConfirmDialog no longer confirms on Enter from its checkbox. Enter activates the focused button, which starts as ABBRECHEN, so a reflex Enter after a remove cancels. Confirming now always means Tab to the destructive button, as contract 1 decided.

Screenshots

TaskDialog opened from HINZUFÜGEN & AUFGABE, and the Einsatz-abschließen confirm. Before, focus stays on the button behind the overlay, so the next key lands there. After, it is inside the dialog.

Before
After

Tests

  • OverlayContractTests: KnownFailures is empty. All 32 clauses pass on all 8 overlay scenarios.
  • OverlayKeyboardTests:
    • TaskDialog from the ETB by keyboard: type the entry, Enter on HINZUFÜGEN & AUFGABE, type, Enter. The task exists and focus is back on the button.
    • Enter on a Kräfte remove confirm removes nothing.
    • PdfExport keeps focus inside while busy.
    • The behaviour's own rules: no primary action in multi-line text, initial focus on the named control, a view's own focus kept, and a replacing overlay keeps focus.
  • make clean ci: all assemblies pass (Acceptance 408/408), no Test Run Failed.

Android: TaskDialog and IncidentDataDialog open with focus in a text field, which raises the soft keyboard. IncidentDataDialog already did that. The button-first overlays (Confirm, About, PdfExport) don't.

🤖 Generated with Claude Code

A new attached behaviour, b:Overlay, carries contract 1 of #545 on each
overlay's root: focus goes inside once it is shown (posted, so it is not
dropped before layout), Tab cycles inside, Esc runs the cancel command,
Enter runs the primary command except in multi-line text, and focus goes
back to the control that opened it. Focus that leaves the overlay while
it is open, as when a busy form disables the focused button, comes back.

All six Pending* overlays use it and lose their code-behind key
handlers. TaskDialog no longer leaves focus in the ETB field behind it.
ConfirmDialog sets no primary command, so Enter activates the focused
button, which starts out as ABBRECHEN: a reflex Enter cancels.

OverlayContractTests has no known failures left. OverlayKeyboardTests
covers the TaskDialog flow from the ETB, PdfExport while busy, Enter on
a remove confirm, and the behaviour's own rules.

Part of #538; the inline panels and flyouts follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Visual already implements ILogical, so the pattern match in IsWithin was
always true (CodeQL cs/useless-type-test). IsLogicalAncestorOf takes the
Visual directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975
DeepDiver1975 merged commit 2fc845e into main Oct 3, 2026
6 checks passed
@DeepDiver1975
DeepDiver1975 deleted the feat/538-overlay-contract branch October 3, 2026 18:45
DeepDiver1975 added a commit that referenced this pull request Oct 3, 2026
…raps (#556)

The build does not warn about a pattern match against a type the value
already has, so it only surfaces as a code-scanning alert on the pull
request, as it did on #555 (Visual is always an ILogical).

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
DeepDiver1975 added a commit that referenced this pull request Oct 3, 2026
The second half of #538. The dialogs got b:Overlay in #555; the panels a
module draws in its own XAML did not, because they are shown by
IsVisible and never leave the visual tree, which is what the behaviour
listened to. None of them took focus, closed on Esc or gave focus back.

b:Overlay.IsInline makes the behaviour open and close with the panel's
own IsVisible instead, and drops the modal pull-back: the page beside a
panel stays live, so a click elsewhere is allowed, and closing then
leaves focus where the Lagebuchführer put it. Arriving at a module by
the rail does not count as opening its panel. b:Overlay.FallbackFocus
names where focus goes when the opener has gone in a rebuild.

Applied to the ETB edit panel, the Funktionen handover, and the
CO-Messung add-house, remove-house, remove-floor and Wohnung-editor
panels. The two removals are destructive confirms: focus starts on
ABBRECHEN and there is no primary command. The Wohnung editor has no
primary command either, since Enter there must not commit (see
CoValueInput). Its ABBRECHEN rebuilds the matrix, so focus falls back
to the house picker; landing on the rebuilt tile is #542's.

The Wohnungen-entfernen panel stays out, as #419 requires: it must not
take focus. Esc on the matrix now cancels it, and the cancel command is
gated on a pending removal so a stray Esc no longer rebuilds the rows
under the focused spinner.

The Forces strength and Scba Sicherheitstrupp flyouts already keep the
contract through Avalonia's Flyout; new tests pin that.

OverlayContractTests checks the four clauses on six inline-panel
scenarios as well; with main's XAML all of them fail.

Fixes #538.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants