Repository navigation
fix(core,lab): reset container padding custom properties on overlay elements (#5208) - #5209
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsBottomSheet (@astryxdesign/core) · View in Storybook
Dialog (@astryxdesign/core) · View in Storybook
MobileNav (@astryxdesign/core) · View in Storybook
Popover (@astryxdesign/core) · View in Storybook
Drawer (@astryxdesign/lab) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
(this is an AI agent comment) Not a review, just findings — I filed #5208, so I built this branch and measured it against the repro. The mechanism is right. Zeroing 1. BottomSheet isn't covered — and it's the component in the issueThe branch is based on 2026-07-21, 634 commits behind main, which predates the BottomSheet promotion into core. BottomSheet renders its own 2. The Dialog change is a no-op todayI measured the variable at each level, using a 40px page padding so the leaked value is distinguishable from Dialog's own 16px: The escape margin is That is also why BottomSheet is the one that breaks: its scroll body is Worth keeping the Dialog change as defence in depth (it is correct, and a future Dialog with an unpadded body would need it), but it isn't what closes #5208. Smaller things
Suggested shape
Repro I used, if it helps — the inner <Section padding={4}>
<BottomSheet isOpen label="Sheet" height="tall" onOpenChange={() => {}}>
<Section padding={4}>content</Section>
</BottomSheet>
</Section>Thanks for picking this up — the diagnosis is right, it just needs the newer base to reach the component that shows it. |
641f74d to
8d0c34e
Compare
|
Thanks for the detailed review feedback, @imdreamrunner, I dont know how i didnt realise the stale branch Updates in this push:
Verification Summary
|
imdreamrunner
left a comment
There was a problem hiding this comment.
(this is an AI agent review, run by @imdreamrunner)
Approving — this closes #5208. Verified on a build of 8d0c34e.
The repro is fixed. Section inside a 640px sheet: 672px before (32px overflow), 640px now. The sheet panel reads --container-padding-inline-start: 0px instead of the leaked 16px.
The tests are real now. I stripped the reset from BottomSheetPanel.tsx, Dialog.tsx and Drawer.tsx and all three new tests failed with expected '' to be '0px' — they discriminate, unlike the earlier toBeInTheDocument() version. Thanks for reworking those.
No harm from the reset. The four patched elements have no padding of their own to escape (Drawer/MobileNav dialogs are padding: 0, the sheet has only its safe-area paddingBlockEnd, and the popover surface keeps padding on the inner content div). Every consumer reads these as var(--container-padding-*, 0px), so with no ancestor leak they already computed 0px — the reset changes a computed value only where an ancestor leaked one, which was the bug. Legitimate escapes still work: a Section inside a Dialog still bleeds to the dialog edge (640px in a 640px dialog, -16px margins), because Dialog's inner wrapper sets real values via container() and shadows the root zero.
Full suites for the five touched components: 351/351. pnpm lint clean. Core-only changeset frontmatter is correct — @astryxdesign/lab is private: true.
Two things I'm deliberately not blocking on; I'll send a follow-up PR for both:
- The other half of the leak.
--astryx-section-paddingand--layout-padding-inner-x/ystill cross the overlay boundary, so an unpaddedSectionin an overlay under<Section padding={10}>renders at 40px instead of the 16px theme default. The overflow is gone; this isn't. - Three overlays still uncovered —
Lightbox(own<dialog>),ContextMenuandHoverCard(they calluseLayerdirectly, so theusePopoversurface reset misses them). Putting the reset inuseLayer's base style covers the last two, and an exportedcontainerPaddingResetwould stop the block being hand-copied — it's in six places now, which is why each new overlay keeps forgetting it.
One nit worth a quick push before merge: pnpm exec prettier --write on the three test files. The expect(...) lines exceed print width and BottomSheet.test.tsx / Drawer.test.tsx each end with a stray blank line. No CI job runs a format check, so it's green either way — it'd just land as drift.
|
Thanks for the fix! Looks good! |
…ndary Follow-up to #5209, which zeroed --container-padding-* on four overlay roots and closed the visible overflow in #5208. Two gaps remained. The variables descendants ADD (--layout-padding-*, and a Section's propagated padding) still crossed the boundary, so an unpadded Section inside an overlay took the page's padding instead of the theme default — 40px where 16px was meant. And Lightbox, ContextMenu and HoverCard were never covered. The reset now lives in one place (overlayPaddingReset, exported from @astryxdesign/core/Layout) instead of being hand-copied per overlay, and moved onto the useLayer root, which covers every layer surface at once. Values descendants subtract are zeroed; values they add are cleared to initial so readers fall through to their own default rather than losing their padding. Section's padding propagation moved from the public --astryx-section-padding token to a private --_section-padding-propagated. The two carried different authority under one name — a theme's value versus one ancestor's — and an overlay could not drop the inherited one without blanking the theme's. Propagated values still win over the theme for nested sections, so behavior is unchanged.
…ndary (#5231) Follow-up to #5209, which zeroed --container-padding-* on four overlay roots and closed the visible overflow in #5208. Two gaps remained. The variables descendants ADD (--layout-padding-*, and a Section's propagated padding) still crossed the boundary, so an unpadded Section inside an overlay took the page's padding instead of the theme default — 40px where 16px was meant. And Lightbox, ContextMenu and HoverCard were never covered. The reset now lives in one place (overlayPaddingReset, exported from @astryxdesign/core/Layout) instead of being hand-copied per overlay, and moved onto the useLayer root, which covers every layer surface at once. Values descendants subtract are zeroed; values they add are cleared to initial so readers fall through to their own default rather than losing their padding. Section's padding propagation moved from the public --astryx-section-padding token to a private --_section-padding-propagated. The two carried different authority under one name — a theme's value versus one ancestor's — and an overlay could not drop the inherited one without blanking the theme's. Propagated values still win over the theme for nested sections, so behavior is unchanged.
Fixes #5208
Problem
When a
<Section>is rendered inside an overlay (Drawer,Dialog,MobileNav) that sits inside a page<Section padding={4}>, the inner<Section>calculates-16pxnegative margins on both sides and overflows the overlay by 32px.Sectionusesmargin-inline-start: calc(-1 * var(--container-padding-inline-start, 0px))to escape parent section padding. Because fixed overlay elements inherit CSS custom properties from ancestor DOM elements, the innerSectionescapes padding that isn't visually there on the overlay panel.Fix
Reset container padding CSS variables to
0pxon root overlay styles inDrawer.tsx,Dialog.tsx, andMobileNav.tsx: