Skip to content

fix(Grid): a responsive column shrinks to a container narrower than minWidth - #12383

Closed
josephfarina wants to merge 5 commits into
mainfrom
rl26-grid-minwidth-phone
Closed

josephfarina wants to merge 5 commits into
mainfrom
rl26-grid-minwidth-phone

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Record change: component:Grid FR2 — a lone track shrinks to a container narrower than minWidth with or without max (it shrank only with max); in a content-sized container a track takes its content's width.

Validation: real-layout browser test (fails on the old template, passes on the fix) and an automated phone-width check sweep (375/390, light and dark, planted controls all correct): more pages pass, none worse; 1280 results unchanged.

User impact

A page that uses Grid with columns={{minWidth: 360}} (no max) on a phone shows cards cut off at the right edge, and the content area scrolls sideways. On a 375px phone with 16px page padding the container is 343px, but each track is at least 360px, so the grid is wider than the screen. The cards' right side, including chart labels and controls, is hidden until the reader scrolls sideways.

Problem and solution fit

  • Why does it overflow? Without max, Grid builds repeat(auto-fill, minmax(<minWidth>px, 1fr)). A track can never be narrower than minWidth, even when the container is narrower.
  • Why does it harm the task? On a phone the reader sees cut-off cards and must scroll sideways to read each one.
  • Why does it matter? {minWidth} without max is a common way to ask for "columns that reflow", and the capped form already shrinks a lone track to the container (min(100%, …)). The two forms disagree only below minWidth, where the uncapped form breaks the page.

The fix wraps the uncapped track minimum in the same min(100%, …) the capped form uses. At or above minWidth the template resolves exactly as before.

Expected behavior and authority

component:Grid FR2 and the responsive states: object-form columns reduce their count to fit. This PR updates FR2 and the narrow-Grid state so a lone track shrinks to a narrow container with or without max. It also records what the capped form already does in a container that takes its width from its content: a track takes its content's width.

Smallest restoration

One template string in Grid.tsx (uncapped branch). Docs: the Grid best practice and the responsive layout guide said {minWidth} alone overflows a phone; they now say one column shrinks to the container, with or without max. No new API or default. A Grid in a container with a definite width at or above minWidth resolves the same tracks as before.

One visible change beyond narrow containers: in a container that takes its width from its content (an inline-block, or a flex item with no width), an uncapped Grid is now as wide as its content instead of minWidth, as a capped Grid already was. The release note and the Grid record say so.

Evidence

  • Reproduction before the change: <Grid columns={{minWidth: 360, repeat: 'fit'}}> with two cards at 375px or 390px. The track is 360px in a 343px or 358px container, and the content area scrolls sideways.
  • Result after the change: the track is 343px or 358px, the cards fit, and nothing scrolls sideways.
  • Test in a container narrower than minWidth: GridNarrowContainer.a11y.chromium.spec.ts opens the Fill vs fit comparison story ({minWidth: 250}, fill and fit, no max) at a 200px viewport. Each grid has one track no wider than the grid, nothing scrolls inside the grid, every item stays inside it, and the page does not scroll sideways. With the old template the same test fails (track 250px in a 136px grid).
  • Picture sweep at phone widths: a set of every page template, the first example block of each component, and a few hundred generated app pages (simple to complex), each opened as a single-file build and as a Vite app in Chromium phone emulation at 375 and 390, light and dark. Automated checks cover sideways overflow, clipping, off-screen text, overlap, contrast, and reachable controls; planted pass and fail controls all came out right. More pages pass after the change, and no page gets worse.
  • No change at normal widths: when the container is at least minWidth, min(100%, Npx) is Npx, so the template resolves as before. The same story test checks that a 1280px viewport still gets more than one track, each at least minWidth. The template sweep at 1280 (light and dark) gives the same check results on every page before and after.
  • Representative unchanged path: capped grids (max) are unchanged.
  • Content-sized container: an uncapped Grid in an inline-block or a flex item with no width now takes its content's width (it took minWidth before). The capped form already behaved this way.
  • Regression tests: Grid.test.tsx pins the uncapped template minmax(min(100%, 360px), 1fr); the browser test above pins the layout.

Scope

Components: Grid

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • CI=1 vitest run --project ui packages/core/src/Grid packages/core/src/theme/themingTargets.test.ts packages/core/src/serverSafeComponents.test.ts (524 passed)
  • node scripts/check-knowledge.mjs (aligned)
  • CI=1 vitest run --project node over the CLI doc-tree, docs-graph and doc-compiler tests (444 passed)
  • playwright test --project chromium packages/core/src/Grid/__tests__/GridNarrowContainer against a built Storybook (2 passed; the narrow test fails on the old template)
  • Real browser (Chromium, phone emulation): 375/390 light and dark, and 1280, before and after.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 17, 2026 8:05pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 8:11 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
…inWidth

columns={{minWidth}} without max built minmax(<minWidth>px, 1fr), so a
360px floor in a phone column pushed the page sideways. The uncapped track
minimum is now min(100%, <minWidth>px), the same floor the capped form uses.
@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): a responsive Grid column never grows wider than its container. Its minimum width is clamped to the container (min(minWidth, 100%)), so a container narrower than minWidth shows one full-width column with no sideways scroll, and every container at least as wide as minWidth lays out as before. The Grid record states this; a real-layout test covers a narrow container and a normal width, and phone-width and 1280px picture sweeps show no page worse.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 946370b

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 94352a8

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 23fa8d9

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
Grid 4.6 kB (+6 B) · 3.8 kB CSS (0) —
TopNavMegaMenu 77.4 kB (+6 B) · 12.7 kB CSS (0) —
GridSpan 3.6 kB (0) · 3.4 kB CSS (0) —

Package size:

  • @astryxdesign/cli 5.36 MB packed (+8 B); no new dependencies
  • @astryxdesign/core 7.65 MB packed (+166 B); no new dependencies

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.

Current run: CI concluded cancelled; parts of this report may be missing.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — the fix for uncapped Grids in narrow containers works. Two documentation gaps need closing before this can be approved.

  • packages/cli/assets/docs/tree/responsive.doc.mjs still says that {minWidth} alone overflows a container narrower than minWidth and that max is what lets the last column shrink (lines 106 and 126), which contradicts the updated Grid docs and the new FR2.
  • The changeset leaves out, and the description's "no visual change at widths at or above minWidth" claim contradicts, that an uncapped Grid in a container sized by its content (for example a flex item with no width in a 600px row, or an inline-block) now shrinks from minWidth to its content's width (250px to 33px in a probe), so please add one sentence about it to the release note and correct that claim.

The narrow-container behaviour is confirmed in the browser: the new spec passes on this head and its case overflows on the base. Heavy CI did not run on this head because the queue was full, so it needs a re-run before merge.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Changeset, uncapped grids no longer overflow a narrower container: verified (Fill vs fit at 200px: 136px track in a 136px grid; new browser spec passes).
  • Changeset, a lone column shrinks as it already did with max: verified (Grid.tsx:364 capped clamp, Grid.tsx:425 uncapped clamp).
  • Changeset, a phone no longer scrolls sideways: verified (375px repro: page width 392px before, 375px after).
  • Description, the uncapped template was minmax(<minWidth>px, 1fr): verified (base Grid.tsx:422).
  • Description, the capped form already uses min(100%, …): verified (Grid.tsx:364).
  • Description, at or above minWidth the template resolves as before and nothing visual changes: true for containers with a definite width (1280px frames identical); false for content-sized containers (finding above).
  • Description, FR2 and the narrow-Grid state are updated: verified (Grid.spec.md FR2 row and Representative states).
  • Description, content-sized behaviour matches what the capped form already does: verified for the capped form (33px before and after); new for the uncapped form (finding above).
  • Description, one template string changes in Grid.tsx: verified (Grid.tsx:425).
  • Description, the best practice now says one column shrinks with or without max: verified in Grid.doc.mjs (three locales); the CLI responsive guide is not updated (finding above).
  • Description, the 360px repro overflows before and fits after: verified with an equivalent fixture.
  • Description, the 200px browser test passes and fails on the old template: verified (2 passed on this head; the same story on the base has a 250px track in a 136px grid).
  • Description, 1280px still has more than one track, each at least minWidth: verified.
  • Description, capped grids are unchanged: verified (capped fixtures pixel-identical).
  • Description, a unit test pins minmax(min(100%, 360px), 1fr): verified (Grid.test.tsx:142-155; 6 of 44 fail on the base).
  • Description, testing commands (524 unit tests, knowledge check, browser spec): verified, all pass.
  • Description, phone and 1280px picture sweep of templates and generated pages: not reproduced.
  • Description, no new public API: verified (zero API surface rows).

Files:

  • .changeset/grid-minwidth-shrinks-narrow.md: finding (missing content-sized note).
  • docs/specs/components/Grid/Grid.spec.md: clear (optional: name the FR2 change under Compatibility).
  • packages/core/src/Grid/Grid.doc.mjs: clear; the CLI responsive guide still needs the same update.
  • packages/core/src/Grid/Grid.test.tsx: clear.
  • packages/core/src/Grid/Grid.tsx: clear.
  • packages/core/src/Grid/__tests__/GridNarrowContainer.a11y.chromium.spec.ts: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Grid/Grid.doc.mjs Resolved
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 23d14be

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — both earlier points are fixed: the CLI responsive guide now matches the new rule, and the release note names the content-sized change. One thing still blocks approval:

  • packages/cli/assets/docs/tree/responsive.doc.mjs ships in @astryxdesign/cli, but the only changeset names @astryxdesign/core, so the required lint's "Check Changeset coverage" step fails; add '@astryxdesign/cli': patch to .changeset/grid-minwidth-shrinks-narrow.md, or run pnpm changeset:new --packages @astryxdesign/cli --category docs.

The narrow-container fix and the unchanged wide layout are confirmed in the browser, and the spec change has an engineering owner's approval for this head. Heavy CI was cancelled on this head because the CI queue was full, so it needs a re-run before merge.

Claims and files checked

Review mode: incremental; reason: none

Claims:

  • Changeset, an uncapped {minWidth} grid no longer overflows a narrower container: verified (Fill vs fit at 200px: 136px track in a 136px grid; 360px phone fixture: 311px track in a 311px grid).
  • Changeset, a lone column shrinks as it already did with max: verified (Grid.tsx:364 capped clamp, Grid.tsx:425 uncapped clamp).
  • Changeset, a phone no longer scrolls sideways: verified (375px page width 392px before, 375px after).
  • Changeset, in a content-sized container an uncapped grid is now as wide as its content, as a capped grid already was: verified (inline-block and flex-item probes 250px to 24.5px; capped 24.5px on both sides).
  • Description, a 360px floor overflows a phone column: verified with an equivalent fixture (360px track in a 311px grid).
  • Description, the uncapped template was minmax(<minWidth>px, 1fr): verified (base Grid.tsx:422).
  • Description, the capped form already uses min(100%, …): verified (Grid.tsx:364).
  • Description, a container with a definite width at or above minWidth resolves the same tracks: verified (1280px frames pixel-identical).
  • Description, FR2 and the narrow-Grid state are updated and record the content-sized case: verified (Grid.spec.md:98, :118).
  • Description, one template string changes in Grid.tsx: verified (Grid.tsx:425).
  • Description, the Grid best practice and the responsive guide now say one column shrinks with or without max: verified (Grid.doc.mjs:34, :143, :161; responsive.doc.mjs:106, :126).
  • Description, no new API or default: verified (0 public-surface rows).
  • Description, the release note and the Grid record name the content-sized change: verified (changeset line 5, FR2).
  • Description, the 200px browser test fails on the old template and passes on the new one: verified by probe (250px track in a 136px grid before, 136px after); the spec is unchanged since it passed on the previous head.
  • Description, 1280px still has more than one track, each at least minWidth: verified (fill 4 × 292px; fit 600px, 600px).
  • Description, capped grids are unchanged: verified (capped fixture pixel-identical).
  • Description, a unit test pins minmax(min(100%, 360px), 1fr): verified (Grid.test.tsx:78-91).
  • Description, testing commands: unit suites 524 passed and the knowledge check aligned, verified; CLI doc tests 352 passed over the doc-compiler and docs-graph suites (the reported 444 covers a wider set); the Playwright run was not repeated here.
  • Description, phone and 1280px picture sweep of templates and generated pages: not reproduced.
  • Description, no internal context in public text: verified.

Files:

  • .changeset/grid-minwidth-shrinks-narrow.md: finding (does not name @astryxdesign/cli).
  • docs/specs/components/Grid/Grid.spec.md: clear (optional: name the FR2 change under Compatibility and migration).
  • packages/cli/assets/docs/tree/responsive.doc.mjs: clear text; needs the CLI changeset above.
  • packages/core/src/Grid/Grid.doc.mjs: clear.
  • packages/core/src/Grid/Grid.test.tsx: clear.
  • packages/core/src/Grid/Grid.tsx: clear.
  • packages/core/src/Grid/__tests__/GridNarrowContainer.a11y.chromium.spec.ts: clear.

Automated review (maintainer link)

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 23fa8d9

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet (its run was cancelled because CI was full, and the CLI smoke test timed out while checking out the repository), so it needs a re-run before merge. The last open point is fixed: the release note now names @astryxdesign/cli for the updated responsive guide, and the changeset coverage check passes.

The narrow-container fix and the unchanged wide layout are confirmed in a real browser, and the Grid spec change has an engineering owner's approval for this head. Two optional follow-ups: the Grid record's compatibility lines (Grid.spec.md:46, :47, :60) still say it changes no runtime behaviour, and a browser case for FR2's content-sized clause would guard it.

Claims and files checked

Review mode: incremental; reason: none

Claims:

  • Changeset, an uncapped {minWidth} grid no longer overflows a narrower container: verified (Fill vs fit at 200px: 136px track in a 136px grid; phone fixture: 311px track in a 311px grid; the new browser spec passes).
  • Changeset, a lone column shrinks as it already did with max: verified (Grid.tsx:364 capped clamp, Grid.tsx:425 uncapped clamp).
  • Changeset, a phone no longer scrolls sideways: verified (375px page width 392px before, 375px after).
  • Changeset, in a content-sized container an uncapped grid is now as wide as its content, as a capped grid already was: verified (inline-block and flex-item probes 250px to 18.4px; capped 18.4px on both sides).
  • Changeset, the note covers both the core and CLI packages: verified (changeset coverage passes; the CLI change is the responsive guide).
  • Description, a 360px floor overflows a narrower phone column: verified with an equivalent fixture (360px track in a 311px grid).
  • Description, the uncapped template was minmax(<minWidth>px, 1fr) and the capped form already uses min(100%, …): verified (base Grid.tsx:422, head Grid.tsx:364).
  • Description, a container with a definite width at or above minWidth resolves the same tracks: verified (1280px frames pixel-identical).
  • Description, FR2 and the narrow-Grid state are updated and record the content-sized case: verified (Grid.spec.md:98, :118).
  • Description, one template string changes in Grid.tsx: verified (Grid.tsx:425).
  • Description, the Grid best practice and the responsive guide now say one column shrinks with or without max: verified (Grid.doc.mjs:34, :143, :161; responsive.doc.mjs:106, :126).
  • Description, no new API or default: verified (0 public-surface rows in every published package).
  • Description, the release note and the Grid record name the content-sized change: verified (changeset line 6, FR2).
  • Description, the narrow browser test fails on the old template: verified by probe (250px track in a 136px grid on the base); the spec passes 2 of 2 on this head.
  • Description, 1280px still has more than one track, each at least minWidth: verified (fill 4 × 292px; fit 600px, 600px).
  • Description, capped grids are unchanged: verified (capped fixture pixel-identical).
  • Description, a unit test pins minmax(min(100%, 360px), 1fr): verified (Grid.test.tsx:78-91).
  • Description, testing commands: unit suites 524 passed, knowledge check aligned and browser spec 2 passed, verified; the CLI doc-test count was not reproduced exactly.
  • Description, phone and 1280px picture sweep of templates and generated pages: not reproduced.
  • Description, no internal context in public text: verified.

Files:

  • .changeset/grid-minwidth-shrinks-narrow.md: clear.
  • docs/specs/components/Grid/Grid.spec.md: clear (optional: compatibility lines 46, 47 and 60).
  • packages/cli/assets/docs/tree/responsive.doc.mjs: clear.
  • packages/core/src/Grid/Grid.doc.mjs: clear.
  • packages/core/src/Grid/Grid.test.tsx: clear.
  • packages/core/src/Grid/Grid.tsx: clear.
  • packages/core/src/Grid/__tests__/GridNarrowContainer.a11y.chromium.spec.ts: clear.

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12680 perf(cli): a template's component line resolves its names in one pass, not one full lookup per name
  Author: Joey <[email protected]>
- #12180 fix(core): Calendar weekday names widen their column instead of overlapping
  Author: Joey <[email protected]>
- #12159 feat(cli): make an icon set inside your own app
  Author: Joey Farina <[email protected]>
- #12383 fix(Grid): a responsive column shrinks to a container narrower than minWidth
  Author: Joey Farina <[email protected]>
- #12374 [fix] Icon: a glyph given as name renders and warns, instead of crashing
  Author: Joey Farina <[email protected]>
- #12453 fix(charts): line, area and band default to straight segments
  Author: josephfarina <[email protected]>
- #12296 fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill
  Author: Joey Farina <[email protected]>
- #12395 fix(CodeBlock): without a code string, CodeBlock names the prop and the fix in development
  Author: Joey Farina <[email protected]>
- #12260 fix(cli): `astryx component Flex` names Stack first
  Author: Joey Farina <[email protected]>
- #12391 fix(core): a two-lane Toolbar wraps instead of squeezing its start lane
  Author: Joey Farina <[email protected]>
- #12427 fix(core): checkbox and radio marks keep their share of the box a theme sizes
  Author: josephfarina <[email protected]>
- #12725 [experimental] cli: with no icon set, experimental icon names the discover search where it lists packs
  Author: Joey Farina <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12738.

@github-actions
github-actions Bot deleted the rl26-grid-minwidth-phone branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 23fa8d97 Deployed Nov 17, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant