Repository navigation
fix(GridSpan): keep long content such as a Tokenizer token in its column - #7528
Conversation
GridSpan is a grid with no column template, so its children sit in one implicit `auto` column. An auto track never shrinks below its item's min-content width, so a Tokenizer with a long token widened the column past the span (and the parent grid cell) instead of truncating. The span's own `min-width: 0` could not stop it, because the overflow happens inside the span. Give the span an explicit `minmax(0, 1fr)` column. The column still fills the span, and children now size to the span the way they do outside a Grid. A new Grid story renders the reproduction from the issue, and its play assertion runs in the story play guard. Fixes #7438
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Recommended for approval: giving GridSpan a minmax(0, 1fr) column keeps a child wider than its cell, such as a Tokenizer with a long token, inside the span without changing any API. The overflow and the fix were confirmed in a browser in both LTR and RTL, and existing Grid stories render unchanged. Nothing is required from you; optionally, also asserting the field's left edge in the new play would let it catch an RTL regression.
[Automated review]
| await expect(span.getBoundingClientRect().right).toBeLessThanOrEqual( | ||
| hostRight + 0.5, | ||
| ); | ||
| await expect(field.getBoundingClientRect().right).toBeLessThanOrEqual( |
There was a problem hiding this comment.
Optional hardening: this checks only the right edge, so it would not catch the overflow in RTL, where the field spills past the left edge instead. Also asserting that the field's left is not less than the host's left - 0.5 would make this check direction-agnostic.
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression44 of 454 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 24 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
User impact
Anyone who puts a field inside
GridSpanhits this when the field's content is wider than the cell. The issue's case is a Tokenizer with a long token, composed asGrid columns={{minWidth: 280, max: 2}}>GridSpan columns="full">VStack>Tokenizer width="100%". The field grows past the grid and its container instead of truncating the token, as it does outside a Grid. After this change, the field stays the width of the cell and the token truncates.Problem and solution fit
GridSpanisdisplay: gridwith no column template (packages/core/src/Grid/GridSpan.tsx,baseStyles.span), so its children sit in one implicitautocolumn. Anautotrack never gets narrower than its item's min-content width, which for a Tokenizer is the width of the long token. The span itself hasmin-width: 0and stays at 500px, but the column inside it grows to about 597px.width="100%"resolves against that oversized column, so the field paints outside the cell. Its remove buttons and end edge land outside the layout, and in RTL the field spills past the left edge of the cell.{minWidth, max}is the documented reflowing shape. It says the last track shrinks to the container rather than overflowing it, and themin-width: 0on the span ("Prevent overflow in grid") shows the same intent for GridSpan. One long value should not break that.The fix gives the span an explicit
grid-template-columns: minmax(0, 1fr). The single column still fills the span, but it can no longer grow to fit min-content, so children size to the span and the Tokenizer's normal truncation applies.Expected behavior and authority
Grid.spec.md(draft) andGrid.doc.mjs: with{minWidth, max}, the grid "drops to one full-width column when narrow", and the last track "shrinks to the container rather than overflowing it".minWidth: 0, // Prevent overflow in gridonGridSpan.Smallest restoration
One declaration in
GridSpan's base style. Supporting changes:GridSpan contains a long token (#7438), renders the issue's composition in a 500px host. Itsplayasserts that the span and the field stack stay inside the host.TARGETSin.github/scripts/story-play-guard.jsso CI runs the assertion in Chromium.@astryxdesign/core.Unchanged: Grid track construction, GridSpan's
columnsandrows, and the Tokenizer itself. Tokens overlapping the clear-all lane are #7375's area; this change doesn't touch Tokenizer files.Evidence
Playwright Chromium against a built Storybook, story
core-grid--grid-span-with-long-content, 500px host:✗ Grid (core-grid--grid-span-with-long-content): AssertionError: expected 628.578125 to be less than or equal to 532.5.✓ Grid (core-grid--grid-span-with-long-content): play passed.core-grid--default,--with-grid-span,--grid-span-with-rowsand--dashboard-layout, taken before and after at 1000px, are byte-identical.Before / after screenshots (LTR and RTL):




Scope
Testing
pnpm vitest run packages/core: 435 files, 12234 tests passed.pnpm storybook:buildthennode .github/scripts/story-play-guard.js --storybook-dir apps/storybook/dist(Chromium, Linux): the Grid target passes. The two PowerSearch near-full-token-row targets fail the same way with and without this change.pnpm build,pnpm lint:strict(0 errors; no warnings in changed files),pnpm -F @astryxdesign/core typecheck:docs,pnpm check:changesets: pass.Real-browser evidence is Chromium only.
Fixes #7438