refactor(ui): shared modal component + ESC consistency fix (#93 review)#188
Merged
Conversation
The architecture review found 7 hand-rolled modal/overlay scaffolds that
diverged: auth/import modals closed on Escape, but the lookup detail and
assembly modals and the recovery dialog did not. A user who learns "ESC
dismisses" got inconsistent behavior.
- web/src/ui/components/modal.ts: openModal({ body, overlayClass,
cardClass, ariaLabel, dismissable, closeButton, onClose }) owning the
overlay + card + ✕ + ESC + backdrop + focus(open)/restore(close)
contract once. role=dialog/aria-modal for a11y. Call sites keep their
feature class (so CSS + e2e selectors are preserved). `body` may be a
builder (close) => HTMLElement for forms. dismissable:false forces a
choice (crash recovery) — no ESC/backdrop/✕.
- Migrate: lookup detail + assembly modals (now close on ESC — the fix),
and main.ts recovery dialog (dismissable:false, structure shared).
- CSS: base .modal-overlay/.modal-card/.modal-card__close.
- modal.test.ts (8): mount, a11y, ESC, backdrop-vs-card, ✕, listener
cleanup/no-double-close, non-dismissable, function body.
Follow-ups (own issues): migrate auth/import/scan overlays onto modal.ts;
extract a shared dropdown helper; add control-height/shadow/z-index
design tokens (the styling-SSoT review).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the architecture review (the filter-bar misalignment turned out to be a symptom of a missing component layer). This extracts the first shared component:
modal.ts.The review found 7 hand-rolled modal/overlay scaffolds that diverged — auth & import modals closed on Escape, but the lookup detail/assembly modals and the recovery dialog did not. A user who learns "ESC dismisses" got inconsistent behavior. That's a real bug, not just duplication.
What changed
web/src/ui/components/modal.ts—openModal({ body, overlayClass, cardClass, ariaLabel, dismissable, closeButton, onClose })owns the overlay + card + ✕ + ESC + backdrop-click + focus-on-open / focus-restore-on-close contract once.role="dialog"/aria-modalfor a11y. Call sites keep their feature class (so existing CSS + e2e selectors are preserved).bodymay be a(close) => HTMLElementbuilder for forms.dismissable:falseforces a choice (crash recovery) — no ESC/backdrop/✕.main.tsrecovery dialog (non-dismissable, structure shared)..modal-overlay/.modal-card/.modal-card__close.Tests
modal.test.ts(8): mount + classes, a11y attrs, ESC closes, backdrop-vs-card click, ✕, listener cleanup / no double-close, non-dismissable mode, function body.Deliberately out of scope (follow-ups worth their own issues)
modal.ts(they already behave correctly — pure dedup).documentlistener).🤖 Generated with Claude Code