fix(docsite): stop blog card grids overflowing on small screens#3394
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| }, | ||
| // Responsive card grid. `min(320px, 100%)` clamps the track to the container | ||
| // so a 320px column never overflows a narrower viewport (e.g. small phones). | ||
| postGrid: { |
There was a problem hiding this comment.
Hmm any reason this wasn't achievable via Grid?
There was a problem hiding this comment.
It's not currently achievable via Grid — that's actually the root cause of the overflow. Grid's responsive API emits its track as repeat(auto-fill|auto-fit, minmax(<minWidth>px, 1fr)), and the minmax() minimum is a fixed <minWidth>px. A grid track never renders narrower than its min, so once the viewport is narrower than minWidth (480px on the home grid, 320px here) the single column is wider than the screen and the page overflows.
To do this via Grid we'd need to change core to clamp the min to the container: minmax(min(<minWidth>px, 100%), 1fr). That's the right long-term fix, but it changes the rendered CSS for every columns={{minWidth}} consumer, so it needs its own PR (snapshot/test updates in Grid.test.tsx, a changeset, broader visual check) rather than riding along in a docsite bug fix. I kept this one scoped to unblocking the overflow and left a note in the PR description that core Grid should be updated separately so no one hits this again.
Happy to open that core Grid follow-up if you'd prefer to fix it centrally instead.
The home "Stay in the know" section and the /blog index built their card
grids with `repeat(auto-fit/fill, minmax(<minWidth>px, 1fr))` (via Grid's
`columns={{minWidth}}`), whose fixed track min (480px / 320px) can't shrink
below the viewport — so on phones the cards overflowed horizontally.
Use a container-clamped track, `minmax(min(<minWidth>px, 100%), 1fr)`, so the
column collapses to the viewport width on small screens. Scoped to the docsite
(local grids) to leave the shared core Grid untouched.
Co-authored-by: Cursor <cursoragent@cursor.com>
bc09b99 to
0cb38a4
Compare
Summary
On small screens the blog cards overflowed the viewport horizontally.
Root cause: both blog card grids were built with
repeat(auto-fit/fill, minmax(<minWidth>px, 1fr))(via the coreGrid'scolumns={{minWidth}}API). A bareminmax(<minWidth>px, 1fr)track can't shrink below its fixed min, so on a viewport narrower than that min the column overflowed the page:BlogShowcase, 2-post layout) usedminWidth: 480→ overflowed on every phone <480px./blogindex (BlogIndex) usedminWidth: 320→ overflowed on ~320px devices.Fix: use a container-clamped track,
minmax(min(<minWidth>px, 100%), 1fr), so the column collapses to the viewport width on small screens and stacks cleanly. Implemented as small local grids in the docsite (leaving the shared coreGriduntouched, per scope).Rationale: the core
GridissueThis overflow is not specific to the blog cards — it's a latent limitation of the core
Grid's responsive API.Gridemits its responsive track as:The
minmax()minimum is a fixed<minWidth>px. A grid track will never render narrower than its min, so whenever the container is narrower thanminWidth, the single column is wider than the viewport and the page overflows horizontally. This affects anycolumns={{minWidth}}usage whereminWidthcan exceed the smallest supported viewport (~320px), which is exactly what happened with theminWidth: 480home grid.The robust, idiomatic CSS fix is to clamp the track min to the container:
minmax(min(<minWidth>px, 100%), 1fr). Themin(<minWidth>px, 100%)lets the track shrink to the container width when there isn't room for the fullminWidth, so it stacks instead of overflowing, while still preferringminWidthwhen space allows.Why fix it locally instead of in core
Grid: changing the core track generation would alter the rendered CSS for everycolumns={{minWidth}}consumer across the system, so it needs its own dedicated change (snapshot/test updates inGrid.test.tsx, a changeset, and broader visual verification) rather than riding along in a docsite bug fix. This PR is scoped to unblocking the docsite overflow; the coreGridshould be updated separately to emitminmax(min(<minWidth>px, 100%), 1fr)so no consumer hits this again.Test plan
/and/blog(document.scrollWidth === innerWidth)Made with Cursor