Layered Escape dismissal (dismiss stack) + cat-modal fixes#52
Merged
Conversation
Escape inside a modal containing an open dropdown or datepicker closed both at once. A new LIFO dismiss-stack util dismisses only the topmost open layer per Escape press; modal/dropdown/datepicker register through it (popups via useDismissablePopup), taginput keeps self-consuming on its input. Modal also: runs open side effects when mounted already open, skips hidden focusable candidates in the focus trap, makes an overflowing body a focusable named region, and gains an axe test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploying catenary with
|
| Latest commit: |
cf53e92
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://09d773ad.catenary-5bw.pages.dev |
| Branch Preview URL: | https://escape-dismiss-stack.catenary-5bw.pages.dev |
A new modal demo holds a dropdown and a datepicker so reviewers can feel the fix: Escape closes only the open popup first, the modal second, with form state preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
The widget accessibility audit's last serious cross-cutting finding (related to interline-io/calact-network-analysis-tool#390, where datepickers are composed inside the Feed Archive modal): Escape pressed while a popup is open inside a modal closed both layers at once, destroying in-progress form state. This adds a shared LIFO dismiss stack so Escape dismisses only the topmost open layer, and folds in the remaining cat-modal audit findings since they share the file.
Layered Escape dismissal
src/util/dismiss-stack.ts: one document-level keydown listener (bubble phase) that, on Escape, dismisses only the top entry and consumes the event. It ignoresdefaultPreventedso components that handle Escape on their own element and let it bubble (cat-dropdown's menu) are respected, and runs in bubble (not capture) phase so components that stopPropagation on their own element (cat-taginput's input) keep Escape from reaching it at all.useDismissablePopupregisters/unregisters its layer on open/close instead of holding a direct document Escape listener, so cat-dropdown and cat-datepicker participate automatically. cat-modal registers its own layer. A popup inside a modal now closes on the first Escape, the modal on the second. A non-closable modal still registers a layer, so it swallows Escape rather than letting it dismiss a surface beneath it.cat-modal fixes (audit P11)
modelValuealready true, not only on the false-to-true transition. Extracted into named functions called from both the watch and onMounted.checkVisibility), so Tab no longer dead-ends on adisplay:nonebutton.modal-card-bodybecomes a focusable named region (tabindex="0",role="region", labeled by the title or aria-label) so keyboard users can scroll it; Safari does not make scroll containers focusable automatically. Overflow is tracked with a ResizeObserver while open and the section already matched the focus-trap selector, so it joins the Tab cycle without extra wiring.Test plan
Generated with Claude Code