Repository navigation
fix(Layout): scope a Layout's padding to its own regions - #6810
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression17 of 436 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Thanks for the detailed fix and evidence. Scoping a Layout's padding to its own regions restores the default inset for a page Layout inside AppShell, and the Card, Section, and Dialog cases correctly keep the container's inset instead of resetting to the default — the new regression tests cover exactly the cases that separate those two behaviors.
One decision is needed from an owner before this can be approved. A padding-less Layout nested inside a Layout with non-zero padding (for example <Layout padding={2}> wrapping a padding-less <Layout>) used to inherit the outer value; it will now use the nearest container inset or the 16px default. That inheritance was not documented and no in-repo caller was found to rely on it, but approval needs an owner to confirm that no supported consumer relied on it — in which case this stands as a contract-restoring fix — or to identify such a consumer, in which case it needs to be handled as an incompatible fix with its migration (putting the same padding on the nested Layout).
Everything else is ready on the current change: no new public API, explicit padding is unchanged, and the focused tests pass.
[Automated review]
ebb80e3 to
b4e8fdf
Compare
There was a problem hiding this comment.
Thanks for the detailed fix and evidence. Scoping a Layout's padding to its own regions restores the default inset for a page Layout inside AppShell, and the Card, Section, and Dialog cases correctly keep the container's inset instead of resetting to the default — the new regression tests cover exactly the cases that separate those two behaviors.
One decision is needed from an owner before this can be approved. A padding-less Layout nested inside a Layout with non-zero padding (for example <Layout padding={2}> wrapping a padding-less <Layout>) used to inherit the outer value; it will now use the nearest container inset or the 16px default. That inheritance was not documented and no in-repo caller was found to rely on it, but approval needs an owner to confirm that no supported consumer relied on it — in which case this stands as a contract-restoring fix — or to identify such a consumer, in which case it needs to be handled as an incompatible fix with its migration (putting the same padding on the nested Layout).
Everything else is ready on the current change: no new public API, explicit padding is unchanged, and the focused tests pass.
[Automated review]
Need: AppShell composes an internal Layout with padding={0}. Layout's
padding was published as the inherited --layout-padding-outer-x/y, so a
page Layout inside AppShell content (or inside any other Layout) inherited
the outer value. Its LayoutHeader, LayoutContent, LayoutPanel, and
LayoutFooter lost their default 16px inset, and page titles and body text
rendered flush against the content edge at every width.
Model: a Layout's padding now writes --layout-padding-own-outer-x/y, which
its regions read ahead of the inherited --layout-padding-outer-x/y that
Card, Section, and Dialog publish through container(). Every Layout,
padding container, and overlay root clears the own value, so it never
reaches a nested Layout's regions. The container-published value is left
alone: a Layout inside a padded Card, Section, or themed Dialog keeps that
container's inset. (Clearing --layout-padding-outer-* on every Layout
instead resets those containers' Layouts to 16px.)
Compatibility: a nested Layout without padding takes the nearest padding
container's inset or the default instead of an ancestor Layout's padding.
Explicit padding on any Layout, Layouts directly in Card/Section/Dialog,
and single Layouts are unchanged. No public API change.
b4e8fdf to
ed90b63
Compare
There was a problem hiding this comment.
Approved at this exact head. The owner settled the compatibility question: each nested Layout owns its own boundary, so a padding-less Layout inside a padded Layout using the nearest container inset or the default is a contract restoration under the layout-regions and container-padding records, and the patch changeset stands. The own-padding values are cleared by every Layout, padding container, and overlay root, so one Layout padding never reaches a nested Layout, while Card, Section, and Dialog insets and explicit padding still win. Rebased cleanly on main; CI is green, including stable visual regression, accessibility, and RTL.
[Automated review]
A Layout placed inside AppShell content, or inside another Layout, inherits the outer Layout's padding. AppShell's own Layout is full bleed, so page titles, body text, and side panels render flush against the screen edge. With this PR a Layout's padding applies only to its own regions, so nested Layouts keep their default 16px inset with no extra props.
At a glance
paddingSecond view: Layouts inside a Card with padding 2, a theme-default Card, and a Section with padding…
Every screenshot, measurement file and repro script for this PR: astryx-pr-evidence/layout-nested-padding
User impact
Anyone who puts a page
LayoutinsideAppShellcontent, or nests oneLayoutinside another. That is common: in a blind agent-built UI benchmark (three AI coding models, 24 real product screens, ~440 Astryx builds), nested Layouts appeared in 28.5% of builds, and the same defect showed up 12 times across 6 real apps built on Astryx.What fails: the nested Layout's
LayoutHeader,LayoutContent,LayoutPanel, andLayoutFooterlose their default 16px inset. The page title and body text sit at 0px from the content edge, and an end panel's outer and bottom edges lose their padding, at 1440 and at 390 alike.AppShellcontentPaddingcannot fix it (it pads theLayoutContentaround the page Layout, which the page Layout's outer wrapper escapes by design).What the fix enables: the page Layout renders with its documented default inset with no extra props. Layouts inside a padded Card, Section, or Dialog keep that container's inset, exactly as today.
Problem and solution fit
AppShellcomposes an internalLayoutwithpadding={0}. Layout published itspaddingthrough the inherited custom properties--layout-padding-outer-x/y, which every Layout region reads. Custom properties inherit through the DOM, so a Layout rendered anywhere inside AppShell's content inherits0pxfor its own regions.Fit: a Layout's
paddingnow applies only to that Layout's own regions. It writes--layout-padding-own-outer-x/y, which the regions read ahead of the inherited--layout-padding-outer-x/y. Every Layout, every padding container (container(): Card, Section, Dialog), and every overlay root clears theownvalue, so it cannot reach a nested Layout's regions. The container-published--layout-padding-outer-x/yis left alone, so a Layout inside a padded container still takes that container's inset.Re-derived from the original source commit
The source commit for this fix reset
--layout-padding-outer-x/ytoinitialon every Layout. That fixes the AppShell case but also discards the value Card, Section, and Dialog publish for the Layouts inside them. Measured in a browser (neutral theme), it moved a Layout inside<Card padding={2}>from 8px to 16px, inside a theme-default Card from 12px to 16px, and inside<Section padding={6}>from 24px to 16px (compare-unchanged.png). This PR keeps the container channel and scopes only the Layout-published value. The regression tests below fail on that original commit.Expected behavior and authority
family:layout-regions(current) FR3: "Header, Content, Footer, and Panel apply outer inset where they touch the Layout boundary and inner inset where they meet another region." A nested Layout has its own boundary; its regions currently apply the outer Layout'spadding={0}instead of any inset.architecture:container-padding(current) INV4: "Named Layout regions apply outer inset where they touch the shell." System model, layer 2:container()resolves Card, Section, and Dialog padding into internal logical-edge and Layout inset variables. That second clause is the channel the original commit broke and this PR preserves.architecture:container-paddingINV1/INV6:--layout-padding-*is internal protocol, not theme API, and overlay roots invalidate it. The new--layout-padding-own-outer-x/ysits inside that name family, is cleared byoverlayPaddingReset, and is registered as a structural var inderivedVarRegistry.test.ts.Layoutprop doc:paddingis "Padding at the layout's outer edges". The component doc and JSDoc now say this padding applies to that Layout's own regions and is not inherited by a nested Layout.component:Layoutspec isdraftand not authoritative. It already records the same scoping choice forcontentWidth("Reset inherited width so nested Layouts without contentWidth keep their released padding",Layout.tsx). This PR applies that precedent topadding.Smallest restoration
Layout.tsx: Layout's inner wrapper clears--layout-padding-own-outer-x/y(next to the existingcontentWidthreset).paddingandpadding={0}now write theownvariables.LayoutHeader/Content/Footer/Panel.tsx: eachvar(--layout-padding-outer-*, spacing-4)read becomesvar(--layout-padding-own-outer-*, var(--layout-padding-outer-*, spacing-4)). The change is mechanical: same fallback, same edges, same republished--container-padding-*pairing.padding.stylex.ts: Layout's padding maps write theownvariables, andoverlayPaddingResetclears them.container.stylex.ts: the shared container base clears theownvariables, so a padded Card/Section/Dialog inside a padded Layout re-establishes its own inset for Layouts inside it.Supporting only: a regression test file, two test-list registrations, one
Layout.doc.mjsexample plus thepaddingprop description, one Storybook story, one changeset.Representative callsite
Evidence
origin/mainbuild, AppShell page with a nested Layout (header, 320px end panel, content). The header title and content text sit at 0px inline and 0px block from their region edge. The panel's padding is16px 0px 0px 16px(outer inline-end and block-end edges are 0). Same at 1440, 390, and 1440 RTL.16px. No horizontal overflow (document width = viewport).Card padding={2}→ 8px; Layout in a theme-default Card → 12px (neutral theme card padding); Layout inSection padding={6}→ 24px; a singleLayout padding={2}→ 8px. The original source commit changed all three container cases to 16px.packages/core/src/Layout/__tests__/nestedPadding.test.tsxresolves each region's inline inset through the injected StyleX rules, walking custom-property inheritance the way the browser does (jsdom does neither).origin/main: 3 failed / 4 passed (AppShell > Layout, full-bleed Layout > Layout,padding={8}Layout > Layout).Measurements (real browser, Chromium, neutral theme)
16px 0 0 16px16px16pxRaw numbers: measurements.json.
Images
Preview story
Core/Layout → "Nested Layout — Inset in AppShell" (
NestedInAppShell) shows the page Layout in AppShell inside a 390px frame, plus the unchanged Cardpadding={2}case; "Nested Layout — Inset in AppShell (960px)" (NestedInAppShellWide) shows the same page at 960px. Both live inapps/storybook/stories/Layout.stories.tsx, with one AppShell per story so each document has a singlemainlandmark.Agent-facing example
astryx component Layoutnow prints "Page with a details panel inside AppShell": an AppShell page with a nested Layout (header, end details panel, content) and no padding props. Thepaddingprop description now states its scope.Scope
Compatibility, and the one decision I need from an owner
Under
spec:AST-017FR5 I classify this ascontract-restoring. Explicitpaddingon any Layout, a Layout directly inside a Card/Section/Dialog, and a single Layout render exactly as before (measured above).One released behavior does change, and an owner needs to confirm the classification: a Layout without
paddingnested inside a Layout with a non-zeropadding(for example<Layout padding={2}>→<Layout>) used to inherit that value (8px). It now uses the nearest padding container's inset or the 16px default. The inheritance was never documented; the only statement was the JSDoc line thatpadding"controls--layout-padding-outer-x", an internal variable (container-paddingINV1). If an owner decides a supported consumer relied on it, this becomes an FR32incompatible-fix, and the migration is to put the samepaddingon the nested Layout. I found no in-repo caller that relies on it. Among the page templates and docs examples, the only nested Layout under a padded Layout is incanvas-editor, and it sets explicit padding on every region, so it renders the same. AppShell (padding={0}) is the source of the defect.No record amendment is required. The
ownvariables belong to the--layout-padding-*family thatcontainer-paddingINV1/INV6 already cover. If owners want the architecture record's "System model, layer 3" sentence to name the Layout-scoped value explicitly, that is a separate documentation edit.Testing
pnpm vitest run packages/core/src/Layout/__tests__/nestedPadding.test.tsxagainstorigin/mainsources, the original source commit's sources, and this PR (results above; log:fail-before.txt).pnpm vitest run packages/core/src/Layout packages/core/src/AppShell packages/core/src/Card packages/core/src/Section packages/core/src/Dialog packages/core/src/theme/derivedVarRegistry.test.ts: all pass.pnpm vitest run packages/core→ 10655 passed, 1 failed. The failure isContextMenu > opens the real menu content in a BottomSheet when requested, which also fails on untouchedorigin/mainin this environment (2 ContextMenu BottomSheet failures there); it does not involve Layout.pnpm -F @astryxdesign/core typecheckandtypecheck:docs: clean.apps/storybookpnpm typecheck: clean (after building the workspace theme/charts/vega packages it imports).prettier --checkon changed files: clean exceptLayout.doc.mjs, which is already unformatted onorigin/main.eslint: 0 errors.pnpm check:repopassed in the pre-commit hook.origin/main, from the original source commit, and from this branch, overlaid into the same Vite + StyleX scaffold with the neutral theme. Playwright/Chromium at 1440×900, 390×844, 1440 RTL, and a 480px unchanged-path page (DPR 2).astryx component Layout --dense: the new example renders under Examples.Global-baseline review receipt (regenerated at this head; 73 matched claims)
node scripts/review-global-baselines.mjs --authority-commit 217f41d74ec41aee7f6895ea53e8b6035831f3b7 --review-head ebb80e3606b65df352d2d611ea37d3775cf00de7 --triggers layout,styling,theming,layering,testing,compatibilityDirect owners resolved first:
family:layout-regions(current; FR3, FR4) andarchitecture:container-padding(current; INV1, INV2, INV4, INV6, System model layer 2).component:Layoutis draft and non-governing.--layout-padding-*family. INV6:overlayPaddingResetclears it (test updated). INV3/INV8–INV11: no bleed, participation, or edge-compensation change.derived[]).contract-restoringproposed. FR32 decision flagged above for an owner.Full machine-readable receipt: review-receipt.json.
Note
Rebased onto
main@217f41dwith no conflicts. At this head, the focused tests, core typecheck, ESLint andcheck:repowere re-run and pass, and the global-baseline receipt was regenerated (same matched claims). Screenshots and measurements were captured againstmain@eedc844; the regression tests that encode them pass at this head.