Skip to content

fix(core,lab): stop the container padding system at every overlay boundary - #5231

Merged
imdreamrunner merged 1 commit into
mainfrom
fix/overlay-padding-var-isolation
Aug 20, 2026
Merged

imdreamrunner merged 1 commit into
mainfrom
fix/overlay-padding-var-isolation

Conversation

@imdreamrunner

Copy link
Copy Markdown
Contributor

Follow-up to #5209. Stacked on it — the first three commits here are #5209's; this PR's own change is the last commit, and the diff cleans up once #5209 merges.

#5209 zeroed --container-padding-* on four overlay roots and closed the visible overflow in #5208. Two gaps remained.

1. Only half the leak was closed

The container padding system talks to descendants through inherited custom properties, but an overlay leaves its parent's visual box while staying a DOM descendant of it. Two families cross that boundary, and they pull in opposite directions:

variable family descendants… leak symptom
--container-padding-* subtract it (bleed margins) content overflows by the page's padding — #5208, fixed by #5209
--layout-padding-*, section propagation add it content over-padded — still broken

So after #5209 an unpadded Section inside an overlay under <Section padding={10}> renders at 40px instead of the 16px theme default. Measured, before this PR:

                      baseline (top level)   under a 40px page Section
Section in a Dialog          16px                     40px   ✗
Section in a BottomSheet     16px                     40px   ✗

Zeroing these would be wrong — they're added, so 0px strips padding rather than restoring it. They're cleared to initial instead, which makes each guaranteed-invalid so readers fall through their own var(…, fallback) chain to the theme default. After this PR both columns read 16px.

2. Three overlays were never covered

Lightbox (its own <dialog>), and ContextMenu + HoverCard (they call useLayer directly, so usePopover's surface reset missed them).

Rather than hand-copy the block a seventh time, the reset moved to useLayer's root — which covers every layer surface at once, including hasSurface: false consumers that the surface style never reached — and is exported once as overlayPaddingReset from @astryxdesign/core/Layout for the <dialog>-based overlays. Net: the four-line block goes from six hand-copied sites to one definition.

The --astryx-section-padding split

Section propagated its explicit padding on the public --astryx-section-padding token, the same name themes set at the theme root. One name, two authorities — a theme's value and one ancestor's — so an overlay could not drop the inherited one without blanking the theme's inside every dialog.

Propagation moved to a private --_section-padding-propagated, read ahead of the public token, so a propagated value still wins over the theme for nested sections. No behavior change and themes are untouched: --astryx-section-padding is still the public token and still reaches inside overlays. Verified in a browser — a theme's 20px reaches a Section inside a Dialog nested under a 40px page Section, while the 40px does not.

Verification

Measured in Chromium against a built @astryxdesign/core, each overlay open inside <Section padding={10}> (40px):

before after
Section in a Dialog / BottomSheet 40px padding 16px (matches top-level baseline)
Section in a Popover 40px 16px
Lightbox root --container-padding-inline-start 40px inherited 0px
theme's --astryx-section-padding inside a Dialog 20px 20px (unchanged)
Section in a 640px sheet (#5208 repro) 640px 640px (unchanged — #5209's fix holds)

packages/core/src/Layout/overlayPaddingReset.test.tsx covers Dialog, BottomSheet, MobileNav, Lightbox and the layer surface. The tests discriminate: emptying the reset fails all 12.

Full suite 530 files / 10,778 tests green; pnpm lint:strict clean (56 pre-existing warnings); pnpm build produces no drift.

Two jsdom limits worth knowing, both noted at the assertions: it echoes the initial keyword instead of resolving it to the guaranteed-invalid value, and it does not inherit custom properties — so the theme-token invariant is guarded at its source (the reset must not name the public token) and verified in a browser.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 19, 2026
@vercel

vercel Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 20, 2026 12:30am

Request Review

@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

BottomSheet (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3127 -
Complexity N/A Very High (249) -
Dialog (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 624 -
Complexity N/A Very High (79) -
Layer (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 791 -
Complexity N/A Very High (87) -
Layout (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1481 -
Complexity N/A Very High (84) -
Lightbox (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 638 -
Complexity N/A Very High (83) -
MobileNav (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 445 -
Complexity N/A Very High (51) -
Popover (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 553 -
Complexity N/A Very High (52) -
Section (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 230 -
Complexity N/A Very High (42) -
Drawer (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 483 -
Complexity N/A Very High (52) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB
@astryxdesign/lab N/A 3.6KB 1.5KB

Accessibility Audit

Status: 2 accessibility violation(s) found — 1 serious, 1 moderate.

Layout - 2 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
  • 🟡 moderate: Ensure landmarks are unique
    • Rule: landmark-unique · Affects 1/18 stories · Learn more

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

…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.
@imdreamrunner
imdreamrunner force-pushed the fix/overlay-padding-var-isolation branch from 7486850 to d4b04b1 Compare August 20, 2026 00:26
github-actions Bot added a commit that referenced this pull request Aug 20, 2026
@imdreamrunner
imdreamrunner merged commit 4aacbbe into main Aug 20, 2026
19 checks passed

This branch was successfully deployed

1 active deployment
Preview — d4b04b10 Deployed Aug 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant