Repository navigation
feat(map): let map mode be contained by an element, not only the viewport - #170
Merged
Merged
Conversation
Map mode rendered the canvas `position: fixed; inset: 0` with every drawer over it fixed too, so it filled the browser window whatever slot the host gave `<sahaj-atlas>`. A site's own header could not sit above the atlas: a static one was painted over, a sticky one floated above the map AND above the widget's drawers. Generalize the FRAME — the element the fixed layer resolves against — from "the compact card's dialog" to "whichever element has taken the containing block", and add a second one on the host's page. `contain: layout` does the re-parenting, so nothing below changes: the canvas, the drawers and the peek strips are byte-identical in both modes. - `lib/overlay.ts`: `setDialog`/`expandedDialog` become `setFrame`/ `frameElement`, one singleton with two reasons. - `views/MapFrame.tsx`: the contained embed's own box. Publishes itself in a callback ref and holds its children back until it has, because `overlayContainer()` is read in render bodies. - `--sy-frame-h: 100%` keys off `data-sy-frame`; `data-sy-expanded` stays the narrower, dialog-only marker. - `DrawerStack` measures the frame for vaul's snap ladder, subtracts its top from `--sy-sheet-top`, and reads its width for the drawer direction. - The camera padding leaves `useIsWideViewport` for the same frame signal: it pads around a panel the frame now decides, and the two boxes were only ever equal because map mode spanned the viewport. Sizing the element is the opt-in, which is what stops "contained map" and "compact card" both firing: a contained map is container-relative, so it asks the floors question and never the viewport-ownership one. An unsized map embed is bit-for-bit unchanged. Closes #169 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The shape #169 exists for: a site's own sticky header, then the atlas below it, with an explicit height on the element. Every page in this server is a shape that has produced a bug, and this is the one where containment is verifiable at all. Also corrects `sidebar-map.html`'s note: its 300×520 element is now a CONTAINED map, so its card is earned by the 360px width floor rather than by map mode not owning the viewport — and the console says so. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The host-facing contract changed, so `docs/embedding.md` and `CHANGELOG.md`
change with it — including the reversal worth calling out: an explicit
height on `<sahaj-atlas>` used to produce the compact card, and now
produces a map inside that box.
Sizing is now one rule for both modes ("give the element a height and the
widget lives inside it"), with a table for what map mode does when you
don't. Adds the stacking answer a contained embed needs, and corrects the
`transform`/`filter`/`contain` warning: a contained map establishes that
containing block itself, so an outer one changes nothing — and reaching
for one to stop a map painting over the page now has a supported
alternative.
The rule files carry the argument rather than the conclusion.
`components.md`'s "map mode requires a full-page slot" section had gone
stale exactly as the ticket said, so it now records which premise was
retired where — every one of them in #161, for the expanded dialog —
and keeps the unchanged half: `contain: layout` still must never sit on
the scope root.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The harness comment said map mode needs a full-page slot and that giving the element a height paints over the page. Both halves are now the opposite of true. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Four cleanup agents over the branch diff. Substantive fixes:
- **`hasMap` + `contained` collapse into one `MapMode`.** Two booleans could
express "contained, with no map", which is meaningless — the same argument
`CompactAction` already makes for its own shape. `decideSlot` now derives
`contained` from the layout `embedLayout` returned rather than from what it
passed in, so one fact has one representation in the module whose whole
justification is that the join is where the bug was. No behavioural
difference today: the two expressions are equivalent on every current path,
which is exactly why the second one is worth deleting before they diverge.
- **The frame-adoption block was hand-copied and had already drifted** within
this branch — `MapFrame` grew an unmount effect its sibling never had, which
could only ever be a second unconditional clear of a singleton. Extracted to
`hooks/use-frame.ts`; the timing contract is stated once and `MapFrame`'s
spec now covers both frames.
- **The cog offset stayed on the viewport** while the panel it clears moved to
the frame — the identical argument this branch wrote out for the camera
padding, applied one place and not the other. A 600px contained map pushed it
384px right for a panel that is not there; a 400px frame clipped it away.
- **`100vw` on the fixed layer** (Modal, anchored panel, peek strip) describes a
box those elements are not in once a frame contains them. `100%` on a fixed
element already resolves against its containing block, so it is the same
number outside a frame — the width half of what `--sy-frame-h` did for height.
`max-w-md` is 448px and a frame can be 360.
- `data-sy-frame` is the whole JS↔CSS contract as a bare literal in three
files; pinned, with the `WIDGET_SCOPE_CLASS` precedent.
- Three rows of the responsive decision table kept a premise this branch
falsified ("viewport == container wherever they apply"). Prose is the only
guard there — `responsive.test.ts` cannot see Tailwind variants.
- "A height cannot appear by accident" was one layout mode too strong: a
stretched flex/grid item is sized with no rule naming the element. The signal
is still right — that IS the host's layout saying where the widget goes — but
hosts are told, since it is the one case where "unchanged unless you gave it
a height" is not literally true.
Declined: hoisting the width measurement so `DrawerStack` and the camera
provider share one ResizeObserver. All four agents flagged the duplicate, and
it is real — but every variant either moves `setPadding` out of the
`MapController` seam or makes `DrawerStack` conditionally consume-vs-measure,
which reintroduces the two-sources-that-can-disagree shape `WidgetWidthContext`
exists to prevent, one level over. Two observers on a node that resizes with
the host's column is the cheaper of the two costs.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two findings both review passes reached independently, plus their tail. **A rect is not a fillable box.** `mapMode` opts an embed into containment from `getBoundingClientRect().height`, which is non-zero for `min-height: 640px` — while `height: 100%` on the frame resolves against the parent's COMPUTED height, which is `auto`. The frame computed to 0, and since it carries `contain: layout` the entire fixed layer resolved against a zero-height containing block: map, drawers and cog all gone, with `data-sahaj-atlas-ready` still attesting a healthy embed. Measured in Chrome 151 on a real host page (frame 1148x0, canvas collapsed, marker true). Reporting alone would not have been enough, because it is a REGRESSION: that same host got the compact card before #169 — a working button and the right advice. So `ContainedFrame` verifies its own box in the callback ref, during the layout phase and before any child has rendered into it, and refuses: it releases the frame, renders its children uncontained (the viewport map they would have had), and says which rule to change. `mapMode` additionally requires both axes, which covers `display: inline-block; height: 640px` — 0x640, where the parent-column width fallback would otherwise clear the floors and contain the map in a box with no width. **Radix poppers still flipped against the window.** Their default collision boundary is empty, which Floating UI reads as the viewport — correct while the widget owned one. In a contained map a menu near the frame's bottom edge places itself into the free browser window below and `overflow-hidden` erases it: a control that does nothing, silently. `frameCollision()` is one helper spread at all five surfaces, and `overlay.popper.test.ts` pins the inventory — because this branch had already made exactly that mistake once, moving the cog offset onto the measured signal in one place and leaving it a viewport media query 480 lines away. The scan immediately caught a fifth file I had missed, then caught itself matching a comment, which is why it strips them like `responsive.test.ts` does. Also: scope the `[data-vaul-drawer]` lookup to our own portal target rather than the host's whole document (a host shipping vaul would win on document order and we would write `--sy-sheet-top` onto their node every frame); guard the rAF rect reads, where a patched `getBoundingClientRect` could kill the loop permanently or a NaN could stop it ever parking; and replace the sheet's last `3dvh`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
ee793f2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0ec3bc52.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-contained-map.sahajatlas.pages.dev |
5 of 26 tasks
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
<sahaj-atlas>adisplay: blockand a height and the map stays in that box — the site's own header above it, content below, nothing painting over either.Changes
The frame is one element carrying
contain: layout, which makes it the containing block for every fixed descendant. Nothing below it changes — the canvas, drawers and peek strips are byte-identical in both modes.src/lib/overlay.ts—setDialog/expandedDialogbecomesetFrame/frameElement: one singleton, two producers. AddsframeCollision().src/views/MapFrame.tsx+src/hooks/use-frame.ts— the frame, and the adoption contract it shares with the dialog (node in state, children gated on it, published in the layout phase becauseoverlayContainer()is read in render bodies).src/lib/embed-slot.ts—mapMode()returns'none' | 'viewport' | 'contained';embedLayouttakes it. Two booleans could express "contained, with no map".src/styles/globals.css—--sy-frame-h: 100%keys offdata-sy-frame;data-sy-expandedstays the narrower, dialog-only marker.src/views/DrawerStack/DrawerStack.tsx— vaul's snap box, the--sy-sheet-topoffset, the drawer direction and the cog offset all move onto the frame.src/hooks/use-map-controller-real.tsx— camera padding leavesuseIsWideViewport()for the same signal: it pads around a panel the frame now decides.z-index
contain: layoutmakes the frame a stacking context, so the widget'sz-30…z-50stop competing with the host's CSS and their page orders the atlas as one element. A sticky header floats over the map the way it floats over any other content.Verification
pnpm sizeOK (embed 302.7 / 310 KiB)Measured in a browser
A new review page (
pnpm review:embed->contained-map.html) models the shape this exists for: a stickyz-index: 100header, then aheight: 640pxelement.1228x640— exactly the host's content box, in a1280x900viewport260 = 560 - 300. Against the window it would be 600 — the sheet entirely below the box (#161's inversion)--sy-sheet-top260px, frame-relative, not the viewport's 4791280x900,--sy-frame-h: 100dvhNotes for reviewer
Two defects both review passes found independently, and one changed the fix. A host writing
min-height: 640pxhas a non-zero rect, so containment engaged — butheight: 100%resolves against the parent's computed height, which isauto. Measured: frame1148x0, everything gone, and the readiness marker stilltrue. A warning alone would have been insufficient because it is a regression: that host got a working compact card before this. So the frame verifies its own box in the callback ref and refuses — releasing, rendering uncontained, and naming the rule to change.One mistake worth flagging. I fixed the Radix popper collision boundary at two call sites; there were five across four components — the same "applied one place and not the other" error I had already made with the cog. It is now one helper with the inventory pinned by
overlay.popper.test.ts, which immediately caught a fifth file I had missed.Every new assertion was made to fail at its real site before being kept. One exception, stated rather than implied:
contained: layout === 'contained'does not fail when reverted — the two expressions are equivalent on every current path. It removes a latent second representation, not a live bug, and no test covers it.Declined findings. All four cleanup agents flagged that
DrawerStackand the camera provider each mount aResizeObserveron the same node. Every fix either movessetPaddingoutside theMapControllerseam or makesDrawerStackconditionally consume-vs-measure, rebuilding the two-sources-that-can-disagree shapeWidgetWidthContextexists to prevent. Also declined:decideSlot's fail-opencatchreturns a viewport takeover — pre-existing, and changing that default is a behaviour decision beyond this ticket.Not in scope, flagged. Wheel-zoom over a contained map will capture host page scroll.
cooperativeGesturesis the standard answer but costs one-finger pan on touch and needs locale strings across ten locales — its own decision.Closes #169
🤖 Generated with Claude Code