Skip to content

docs(dialogs): document ConfirmDialog focus and escape contract#779

Merged
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Meet-hybrid:docs/dialogs-confirm-dialog
Jul 26, 2026
Merged

docs(dialogs): document ConfirmDialog focus and escape contract#779
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Meet-hybrid:docs/dialogs-confirm-dialog

Conversation

@Meet-hybrid

@Meet-hybrid Meet-hybrid commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the canonical reference for ConfirmDialog in docs/components/ConfirmDialog.md and locks every documented guarantee in as an executable spec via src/components/__tests__/ConfirmDialog.test.tsx.

What changed

  • New: docs/components/ConfirmDialog.md — every ConfirmDialogProp with defaults (confirmLabel = "Confirm", cancelLabel = "Cancel", tone = "default"), the role="dialog" vs role="alertdialog" behavior, the shared useDialogFocusTrap wiring, the FOCUSABLE_SELECTORS list, the empty-focusable fallback, Escape and backdrop contracts, and the explicit caller-responsibility contract with src/components/ActionPanel.tsx as the worked example, including the event.currentTarget capture pattern that beats static ref={triggerRef} props when several buttons share a dialog.
  • Expanded: src/components/__tests__/ConfirmDialog.test.tsx — 27 tests covering defaults, backdrop click, ARIA wiring, repeated open/close cycles, pre-existing aria-hidden / inert preservation across cleanup, the no-focusable fallback, the caller-owned focus-restoration contract, and jest-axe audits for both tones. Module coverage: Lines 100%, Statements >= 95% (Branches 91%, Functions 87.5%).

Validation

  • npm run lint — clean.
  • npm test — 1278/1278 pass across 73 suites (including 27 new ConfirmDialog tests).
  • npm run build failed in the local sandbox due to a missing @tailwindcss/oxide-linux-x64-gnu native binding (a Tailwind optional-dependency install issue, unrelated to these changes). Should be red in CI; please re-run there.
    closes Document the ConfirmDialog focus-trap contract and caller responsibilities #435

Add docs/components/ConfirmDialog.md as the canonical reference for
the dialog's focus-trap contract and caller responsibilities. Document
every ConfirmDialogProp including the 'Confirm' / 'Cancel' label
defaults, the role='dialog' vs role='alertdialog' tone behavior, the
shared useDialogFocusTrap wiring, the FOCUSABLE_SELECTORS list with
its empty-focusable fallback, the Escape and backdrop contracts, the
aria-hidden + inert background hiding rules, and the explicit rule
that callers must retain a trigger ref and restore focus themselves.

Use src/components/ActionPanel.tsx as the worked example — including
the 'capture event.currentTarget at click time' pattern that beats
static ref={triggerRef} props when several buttons share a dialog.

Expand src/components/__tests__/ConfirmDialog.test.tsx to lock in the
contract as an executable spec: defaults, backdrop click, ARIA wiring
including useId across renders, repeated open/close cycles, pre-existing
aria-hidden and inert preservation across cleanup, no-focusable
fallback via the shared hook, caller-owned focus restoration, and
per-button focus spies that catch any future regression where Escape
causes ConfirmDialog to refocus itself. Adds two jest-axe audits.
Module coverage: Lines 100%, Statements >= 95%.
@mikewheeleer
mikewheeleer merged commit fd108bb into Talenttrust:main Jul 26, 2026
1 check passed
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.

Document the ConfirmDialog focus-trap contract and caller responsibilities

2 participants