Skip to content

chore(Storybook): Keep the as prop off the Chromatic variant matrix - #2906

Open
VincentSmedinga wants to merge 3 commits into
developfrom
chore/exclude-as-prop-from-variant-matrix
Open

chore(Storybook): Keep the as prop off the Chromatic variant matrix#2906
VincentSmedinga wants to merge 3 commits into
developfrom
chore/exclude-as-prop-from-variant-matrix

Conversation

@VincentSmedinga

@VincentSmedinga VincentSmedinga commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Describe the pull request

Links

The test stories carry the !dev tag, so they are not in the sidebar of the deploy; the links above open them directly.

What

The as prop no longer gets a row of its own in the variant matrix that the Test stories render for Chromatic. Three test stories shrink as a result: Grid from 22 rows to 13, Row from 18 to 16, and Column from 16 to 14.

Why

buildVariantMatrix puts every prop the argTypes offer on the prop axis and renders one row per non-default value. For as that means one row per allowed tag, and every one of those rows is pixel-identical to the baseline, because swapping the element a component renders does not change how it looks.

Grid is where this cost the most. Its ten tags produced ten rows sharing one appearance, 4878px of a 9117px story, so a fifth of what Chromatic snapshotted for Grid was a copy of the row above it.

How

buildVariantMatrix already had this idea. ARIA_ONLY_PROP_NAMES existed because varying an accessible name also produces a cell identical to the baseline. as belongs to the same category, so rather than add a second list beside it, the constant is now NON_VISUAL_PROP_NAMES and covers both. Its comment carries the reason, which the name alone does not give.

ol and ul are the one case where a tag genuinely could change the appearance, since a browser indents a list and draws markers. They render like a div only because .ams-grid:is(ol), .ams-grid:is(ul) and the matching Subgrid rules reset them, and because .ams-grid__cell:is(li) takes display: block for a Safari marker bug. That reset is covered by the ListCase and GridListCase blocks of the Grid test story, which put a list Grid and Subgrid beside identical plain ones. Those blocks are untouched, and they are what makes the matrix rows redundant rather than the other way round. Only gridTags contains ol and ul; rowTags, columnTags, spotlightTags and breakoutCellTags are article, div and section only.

Merging #2907 put two lists next to each other, so each comment now says which one to reach for. NON_VISUAL_PROP_NAMES holds props that cannot change the appearance at all; UNVARIED_PROP_NAMES holds props whose values do look different and are snapshotted somewhere else, as svg is by Icon. as belongs to the first: leaving it out is not a decision about coverage, there is simply nothing for a snapshot to catch.

That merge also matters for the guard #2907 added. as reaches buildVariantMatrix with options, since asArgType gives it a control, so it is exactly the kind of prop that guard throws for once its type fails to resolve. Excluding it from the axis puts it out of that check's reach, which is correct because leaving it unvaried is deliberate. Two of the guard's tests moved with it: the one that showed a message naming more than one prop used as as an example and now uses gapVertical, and a new test covers as offering options without throwing.

Eight components take an as prop, but only three test stories change. Grid Cell, Grid Subgrid and Breakout Cell have no test story of their own, and the Spotlight and Breakout test stories write out one composition by hand instead of calling renderComponentVariants, as the comment in the Breakout story explains.

Verified in Chromium at 1440px by counting the children of the variants wrapper before and after: 22 to 13, 18 to 16, and 16 to 14, with every remaining row distinct. The Grid story is 7389px tall where it was 9117px.

Checklist

Before submitting your pull request, please ensure you have done the following. Check each checkmark if you have done so or if it wasn't necessary:

  • Add or update unit tests
  • Add or update documentation
  • Add or update stories
  • Add or update exports in index.* files
  • Comment /chromatic test and verify visual regression tests pass
  • Start the PR title with a Conventional Commit prefix, as explained here.

Additional notes

Expect a Chromatic diff on the Grid, Row and Column test stories, and nothing else. All of it is deletions: the removed rows are the tag variants, and every row that remains is unchanged.

documentation/storybook.md gained a sentence, since its description of what the matrix leaves out was the place a reader would look for this rule.

Swapping a component's tag never changes how it looks, so every non-default
tag rendered a row identical to the baseline. Generalise the aria-only
exclusion to cover every prop that cannot change appearance.

The Grid test story drops from 22 rows to 13, Row from 18 to 16 and Column
from 16 to 14.
@VincentSmedinga
VincentSmedinga requested a review from a team as a code owner August 7, 2026 09:19
Copilot AI review requested due to automatic review settings August 7, 2026 09:19
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for React components

Status Category Percentage Covered / Total
🟢 Lines 100% 1102 / 1102
🟢 Statements 100% 1170 / 1170
🟢 Functions 100% 292 / 292
🟢 Branches 100% 866 / 866
File CoverageNo changed files found.
Generated in workflow #427 for commit b6238e4 by the Vitest Coverage Report Action

Copilot AI 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.

Pull request overview

This PR updates the Storybook Chromatic “variant matrix” generation to exclude the as prop from the prop-axis, because varying as for these layout components produces visually identical snapshots and adds substantial redundant snapshot height.

Changes:

  • Rename ARIA_ONLY_PROP_NAMESNON_VISUAL_PROP_NAMES and include as in that exclusion list in buildVariantMatrix.
  • Add a unit test ensuring as does not create rows on the prop axis.
  • Update Storybook documentation to state that non-visual props (including as) are excluded from the matrix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
storybook/src/_common/buildVariantMatrix.ts Excludes as (alongside accessible-name-only props) from the prop axis to avoid redundant visual variants.
storybook/src/_common/buildVariantMatrix.test.ts Adds coverage verifying as does not contribute prop-axis entries.
documentation/storybook.md Documents that non-visual props (accessible name props and as) are omitted from the matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 420 kB

ℹ️ View Unchanged
Filename Size
packages-proprietary/react-icons/dist/index.esm.js 55.3 kB
packages-proprietary/temp/assets-fonts.tar.gz 168 kB
packages-proprietary/temp/assets-others.tar.gz 117 kB
packages-proprietary/tokens/dist/compact.css 600 B
packages-proprietary/tokens/dist/index.css 10.9 kB
packages-proprietary/tokens/dist/lo-fi.css 1.56 kB
packages/css/dist/index.css 17.7 kB
packages/react/dist/index.esm.js 48.7 kB
packages/react/dist/index.js 483 B

compressed-size-action

…rop-from-variant-matrix

# Conflicts:
#	storybook/src/_common/buildVariantMatrix.ts
@VincentSmedinga

Copy link
Copy Markdown
Contributor Author

Probably best to merge this after our Chromatic plan has room again – or else these changes will surprisingly appear in later, unrelated regression tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants