Repository navigation
fix(Badge): a badge is as wide as its label, and never stretches in a Grid cell or a VStack - #12053
Conversation
… Grid cell or a VStack
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 1c2fc4b |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Badge · Storybook | 4.4 kB (+14 B) · 4.0 kB CSS (+16 B) | 232 (+1) | ✓ · ✓ · — |
| ChatTokenizedText | 7.6 kB (+14 B) · 4.0 kB CSS (+16 B) | — | — · — · — |
| ChatComposerDrawer | 18.2 kB (+12 B) · 4.7 kB CSS (+14 B) | — | — · — · — |
9 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| MultiSelector | 101.5 kB (+13 B) · 17.7 kB CSS (+12 B) | — | — · — · — |
| ChatToolCalls | 31.6 kB (+9 B) · 8.4 kB CSS (+14 B) | — | — · — · — |
| ChatComposer | 84.6 kB (+7 B) · 12.9 kB CSS (+12 B) | — | — · — · — |
| ChatComposerInput | 82.3 kB (+8 B) · 12.1 kB CSS (+10 B) | — | — · — · — |
| ChatComposerTokenElement | 82.3 kB (+8 B) · 12.1 kB CSS (+10 B) | — | — · — · — |
| lab/TabBarMoreList | 102.0 kB (+14 B) · 1.8 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 363.1 kB (+8 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 370.0 kB (+7 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 173.7 kB (+6 B) · 1.9 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.61 MB packed (+140 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested: the fix works, but the Badge record does not yet state its compatibility effect.
- The Badge record's Compatibility class (
docs/specs/components/Badge/Badge.spec.md, lines 56-58) and its Compatibility/readiness row (line 41) still describe only the earlierdir="ltr"change, so add that FR3 is a visible, non-breaking layout correction (a badge alone in a grid cell or on a stack's cross axis keeps its content width), as other component records do.
The new browser spec fails on main for the Grid and VStack cases and passes with this change, and the crowded-row and Larger text checks are unchanged. One optional suggestion: the new comment in Badge.tsx (lines 51-55) can be shorter and in the present tense, as noted inline.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim, title: a badge is as wide as its label and never stretches in a Grid cell or a VStack. Verified: the new spec fails on
mainand passes here. - Claim, changeset: a lone badge in a Grid cell or a VStack no longer stretches, and in a crowded HStack it still shrinks with an ellipsis. Verified: Grid badges go from 156 px to 62.6 and 51.1 px, the VStack badge from 320 px to 56.1 px, and the crowded-row badge stays 52 px with its label cut on both sides.
- Claim, cause: the root is
inline-flexwith anautowidth, which a Grid cell and a VStack's cross axis stretch. Verified: Grid and Stack set no alignment by default. - Claim, a flex row still shrinks the badge through its flex basis and the existing min and max widths. Verified by the crowded-row case.
- Claim, the record already describes the badge as a compact one-line pill. Verified in substance: the wording is the record's Design relationships row for the root, which cites FR1.
- Claim, one style declaration with FR3, the summary row and the label description updated, and no new prop, default or theme target. Verified: the built API surface is unchanged.
- Claim, the evidence: failures before the change, measurements after it (more than 40 px narrower in the Grid, under half the stack), and an unchanged crowded row and Larger text spec. Verified by running the specs on both sides.
- Claim, pages built from templates hit the bug. Not checkable in the repository: no shipped page template puts a lone badge in a stretching stack or grid.
- Claim, testing: 13 Playwright and 106 Vitest tests pass, and the knowledge and changeset checks pass. Verified.
- Claim, writing rubric results are none and the open question is unchanged. Verified.
- Claim, scope checklist: one defect, no tagalong, nothing hidden under the fix label, and no internal context. Verified: one style change, an unchanged API surface, and no internal references in the added text.
- File
.changeset/badge-fits-its-label.md: clear. - File
apps/storybook/stories/Badge.stories.tsx: clear. - File
docs/specs/components/Badge/Badge.spec.md: compatibility statement finding. - File
packages/core/src/Badge/Badge.doc.mjs: clear. - File
packages/core/src/Badge/Badge.tsx: clear, with one optional comment suggestion. - File
packages/core/src/Badge/__tests__/BadgeInLayouts.a11y.chromium.spec.ts: clear.
|
/approve-spec 08da884 |
There was a problem hiding this comment.
Approved pending CI: the CI run on this head was cancelled because CI was full, so its build and test jobs have no result yet; re-running CI is the next step. The Badge record's compatibility notes now name the FR3 layout correction, which resolves the earlier change request, and the new browser spec fails without this change for the Grid and VStack cases and passes with it.
One optional suggestion: the new comment in Badge.tsx (lines 51-54) can drop "lets it go under" and the sentence that restates fit-content, as noted inline.
Claims and files checked
Review mode: full; reason: spec-record
- Claim, title: a badge is as wide as its label and never stretches in a Grid cell or a VStack. Verified: the new spec fails on the base and passes here.
- Claim, changeset: a lone badge in a Grid cell or a VStack no longer stretches, and in a crowded HStack it still shrinks with an ellipsis. Verified: Grid badges go from 156 px to 62.6 and 51.1 px, the VStack badge from 320 px to 56.1 px, and the crowded-row badge stays 52 px with its label cut on both sides.
- Claim, changeset: a patch release of the core package. Verified: no public API changes, and the changeset check passes.
- Claim, cause: the root is inline-flex with an auto width, which a Grid cell and a VStack's cross axis stretch. Verified: Grid and Stack set no alignment by default.
- Claim, pages built from templates hit the bug. Verified in mechanism: any lone badge in a default VStack or Grid stretched on the base; no shipped page template places one that way.
- Claim, a flex row still shrinks the badge through its flex basis and the existing minimum and maximum widths. Verified by the crowded-row case.
- Claim, FR3 is amended in one describing clause and the record already calls the badge a compact one-line pill. Verified: the FR3 clause is the only requirement change, and the pill wording is the record's design row for the root.
- Claim, one style declaration with a comment, FR3, the summary row and the label description updated, and no new prop, default or theme target. Verified: the built API surface is unchanged; the follow-up commit also updates the record's compatibility notes.
- Claim, the evidence: failures before the change, measurements after it (more than 40 px narrower in the Grid, under half the stack), and an unchanged crowded row and Larger text spec. Verified by running the specs on both sides.
- Claim, testing: 13 Playwright and 106 Vitest tests pass, and the knowledge and changeset checks pass. Verified.
- Claim, testing: Prettier and ESLint on the changed files. Verified for the TypeScript and Markdown files; the doc file keeps formatting it already had on
main, which no check enforces. - Claim, writing rubric results are none and the open question is unchanged. Verified.
- Claim, scope checklist: one defect, no tagalong, nothing hidden under the fix label, and no internal context. Verified.
- File
.changeset/badge-fits-its-label.md: clear. - File
apps/storybook/stories/Badge.stories.tsx: clear. - File
docs/specs/components/Badge/Badge.spec.md: clear; the compatibility notes match FR3. - File
packages/core/src/Badge/Badge.doc.mjs: clear. - File
packages/core/src/Badge/Badge.tsx: optional comment-style suggestion. - File
packages/core/src/Badge/__tests__/BadgeInLayouts.a11y.chromium.spec.ts: clear.
| // A badge is as wide as its label. A grid cell and the cross axis of a | ||
| // stack stretch a child whose width is `auto`. In a flex row the badge | ||
| // still shrinks: its flex basis follows this width, and the minimum below | ||
| // lets it go under. |
There was a problem hiding this comment.
Optional (comment style): "lets it go under" is vague, and the first sentence restates what fit-content does. A version that keeps only the reason:
// A grid cell and a stack's cross axis stretch an `auto` width. In a flex
// row, the flex basis follows this width, and `minWidth: 0` below lets the
// badge shrink under its content width.
User impact
A
Badgeplaced on its own in aGridcell or aVStackstretched into a bar across the cell or the stack. A grid cell and the cross axis of a vertical stack stretch a child whose width isauto, which is the default for both, and Badge's root left its widthauto. Pages built from templates hit it on their own: a status badge under a heading in aVStackbecame a full-width colored bar, and a badge in a card grid filled its whole cell.Problem and solution fit
inline-flexwithwidth: auto. As a grid item or a flex item on the cross axis, anautowidth stretches to the cell or the stack.Grid,VStack) should not change what a badge looks like.width: fit-contenton the root keeps the badge as wide as its label in a grid cell and a stack. In a flex row it still shrinks: its flex basis follows this width, and the existingmin-width: 0andmax-width: 100%let it go below its content, so a crowded row still cuts the label with an ellipsis inside the badge.Expected behavior and authority
component:BadgeFR3 (amended in this PR, one describing clause): the root is as wide as its content, so it does not stretch to fill a grid cell or the cross axis of a stack; it is capped at the inline size of its container and may shrink below its content size, with the label cut by an ellipsis. FR1 already describes the badge as a compact one-line pill.Smallest restoration
One style declaration (
width: 'fit-content') on Badge's root, with a comment saying why; the Badge record's FR3 and summary row describe it; the label prop description says it. No new prop, default or theme target.Evidence
Core/BadgeIn layouts story at Badge's current source: badges in a two-column Grid are as wide as their cells, and a badge in a VStack is as wide as the stack (the new browser spec fails on both cases).BadgeInLayouts.a11y.chromium.spec.tsmeasures each badge as it is and withwidth: autoin the Grid, VStack and HStack cases. Without the change the Grid and VStack cases fail; with it all three pass.Scope
Components: Badge
Writing rubric results
R1 narration: none; the FR3 clause and the summary row state what the badge does.
R2 research: none in the record.
R3 evidence: the new verification row cites the browser spec and the story, not a change.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: OQ1 is unchanged and still unanswered.
R7 project status: none.
Testing
pnpm storybook:build, thenpnpm exec playwright test BadgeInLayouts BadgeLargerText(Chromium): 13 passed; with Badge's current source, the two new Grid and VStack cases fail.pnpm exec vitest run --project ui packages/core/src/Badge packages/core/src/Grid packages/core/src/Stack(106 tests)pnpm check:knowledge;node scripts/check-changesets.mjs; Prettier and ESLint on the changed files.