cat-dropdown / cat-datepicker: render popups in the top layer (fix clipping in modals)#54
Merged
Conversation
The menu and calendar were clipped by any ancestor with overflow auto/hidden, most visibly a scrollable modal body. Render them in the browser top layer via the Popover API (like cat-tooltip since 0.3.0) through a new useAnchoredPopover composable: showPopover with fixed viewport coordinates, vertical flip when the preferred side lacks room, viewport clamping, and reposition on scroll/resize. The element stays in place in the DOM, so scoped styles, ARIA relationships, focus management, and click-outside containment are unchanged. Browsers without the API keep the absolute-positioning fallback. The positioning math is a pure, unit-tested function. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploying catenary with
|
| Latest commit: |
f5e89cd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://be6d470c.catenary-5bw.pages.dev |
| Branch Preview URL: | https://popup-top-layer.catenary-5bw.pages.dev |
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
A dropdown menu or datepicker calendar opened inside a scrollable container (most visibly a
cat-modalbody, which now hasoverflow: auto) was clipped at the container's edge. This affects real usage: CALACT's Feed Archive modal (interline-io/calact-network-analysis-tool#390) composes datepickers inside a modal, so the calendar was cut off. cat-tooltip solved the same class of problem in 0.3.0 with the Popover API; this brings cat-dropdown and cat-datepicker in line.Changes
src/util/anchored-popover.tscomposable. When the Popover API is available it setspopover="manual"on the popup, shows it withshowPopover(), and positions it with fixed viewport coordinates computed from the trigger's bounding box. The top layer escapes ancestor overflow clipping, z-index stacking, and transformed containing blocks.manual(notauto) so the popup does not light-dismiss outside the components' own Escape/click-outside handling.aria-controls/aria-activedescendant, focus management, and click-outside containment viaroot.contains()are all unchanged.computePopoverPositionwith 8 unit tests (alignment, flip both directions, no-flip, horizontal clamp, left-margin clamp, oversized clamp).Test plan
Generated with Claude Code