Skip to content

fix(GridSpan): keep long content such as a Tokenizer token in its column - #7528

Merged
cixzhang merged 1 commit into
meta:mainfrom
WeAreResilience:fix/7438-tokenizer-gridspan-overflow
Oct 17, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
WeAreResilience:fix/7438-tokenizer-gridspan-overflow

Conversation

@WeAreResilience

Copy link
Copy Markdown
Contributor

User impact

Anyone who puts a field inside GridSpan hits this when the field's content is wider than the cell. The issue's case is a Tokenizer with a long token, composed as Grid 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

  1. Why does it overflow? GridSpan is display: grid with no column template (packages/core/src/Grid/GridSpan.tsx, baseStyles.span), so its children sit in one implicit auto column. An auto track never gets narrower than its item's min-content width, which for a Tokenizer is the width of the long token. The span itself has min-width: 0 and stays at 500px, but the column inside it grows to about 597px.
  2. Why does it hurt? 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.
  3. Why does it matter? {minWidth, max} is the documented reflowing shape. It says the last track shrinks to the container rather than overflowing it, and the min-width: 0 on 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) and Grid.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".
  • The existing minWidth: 0, // Prevent overflow in grid on GridSpan.
  • The issue's comparison case: the same Tokenizer directly in the 500px container already truncates.

Smallest restoration

One declaration in GridSpan's base style. Supporting changes:

  • A Grid story, GridSpan contains a long token (#7438), renders the issue's composition in a 500px host. Its play asserts that the span and the field stack stay inside the host.
  • The story is added to TARGETS in .github/scripts/story-play-guard.js so CI runs the assertion in Chromium.
  • A patch changeset for @astryxdesign/core.

Unchanged: Grid track construction, GridSpan's columns and rows, 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:

Direction Before: span / field width After: span / field width
LTR 500 / 596.6 500 / 500
RTL 500 / 596.6 500 / 500
  • Reproduction before the change: the play guard on a Storybook built from main plus only the new story fails with ✗ Grid (core-grid--grid-span-with-long-content): AssertionError: expected 628.578125 to be less than or equal to 532.5.
  • Result after the change: ✓ Grid (core-grid--grid-span-with-long-content): play passed.
  • Representative unchanged path: screenshots of core-grid--default, --with-grid-span, --grid-span-with-rows and --dashboard-layout, taken before and after at 1000px, are byte-identical.
  • Regression test or other mutation-sensitive proof: the play guard target above fails when the declaration is removed.

Before / after screenshots (LTR and RTL):
before-ltr
after-ltr
before-rtl
after-rtl

Scope

  • 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

  • pnpm vitest run packages/core: 435 files, 12234 tests passed.
  • pnpm storybook:build then node .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

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
@vercel

vercel Bot commented Oct 14, 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 Oct 14, 2026 3:46pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2026
@astracat-bot

astracat-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 15, 2026, 1:24 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 14, 2026
@WeAreResilience
WeAreResilience marked this pull request as ready for review October 14, 2026 15:50

@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.

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(

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.

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.

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

44 of 454 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 238,081
Chat Full AI Chat probe dark 237,048
Markdown Default probe light 159,625
Markdown Default probe dark 158,986
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
TableRowExpansion Detail Panel neutral dark 5,150
TableRowExpansion Detail Panel neutral light 4,068

and 24 more.


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

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 17, 2026
@cixzhang
cixzhang merged commit c35e7ac into meta:main Oct 17, 2026
51 checks passed
@WeAreResilience
WeAreResilience deleted the fix/7438-tokenizer-gridspan-overflow branch October 17, 2026 16:09

This branch was successfully deployed

1 active deployment
Preview — 78fc4330 Deployed Oct 14, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Tokenizer with a long token overflows a native GridSpan despite width="100%"

2 participants