Skip to content

fix(core): a shorthand never follows its own longhand in one style merge - #12316

Closed
josephfarina wants to merge 3 commits into
mainfrom
rl-17c-shorthand
Closed

josephfarina wants to merge 3 commits into
mainfrom
rl-17c-shorthand

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Three component states had a different computed style in Storybook and in the published CSS. On screen they rendered the same in both builds at the base, so this is about computed values, not pixels:

Component and state Published CSS (npm) Storybook
Ordered List with hasDividers: column gap between number and text 8px 0px
Vertical Stepper, indicatorPosition="on-track": flexible connector flex-shrink 0 1
PowerSearch bottom-sheet trigger with tokens: inline padding 4px 0px

Each one is a style merge where a later style sets a shorthand (gap, flex, padding) after an earlier style sets one of its longhands (columnGap, flexShrink, paddingInline).

Problem and solution fit

  • Why: Storybook compiles StyleX with styleResolution: 'application-order', where the later style wins. The published build uses property-specificity, where a longhand beats a shorthand whatever the order. A shorthand placed before its longhand resolves the same way under both. A shorthand placed after its longhand does not.
  • Why it matters: Storybook is where a component's look is reviewed. A shorthand after a longhand can show reviewers one result and ship another; here no frame differed yet, but the next layout that depends on the value would.
  • The fix: the later style sets the same longhands the earlier style sets, so the merge is between the same properties and the later style wins in every build. The authored intent, the modifier winning, is what Storybook already showed.

Expected behavior and authority

A component paints the same in every supported build of its CSS. Each state above now has one value under both resolutions.

Smallest restoration

  • List withDividers: gap: 0 → rowGap: 0. The column gap between number and text stays.
  • Stepper otSegFlexV: flex: 1 → flexGrow: 1, flexShrink: 1, flexBasis: '0%'.
  • PowerSearch triggerWithTokens: padding: 0 → paddingBlock: 0, paddingInline: 0.
  • SideNavHeading: the plain collapsed heading (an icon, no link or menu) merged root with rootCollapsed, whose paddingInline: 0 came after root's longhands and so applied in neither build. That merge now uses rootCollapsedCentered (justifyContent: 'center' only), so the heading keeps its 40px width and icon position exactly as before. The other rootCollapsed merges are unchanged.
  • lab DiffViewer: removes markerSlim (paddingInline: 0 after the marker's longhands). It never applied in either build (measured: the marker keeps 4px/8px in both), so removing it changes nothing.
  • A new lint rule, @astryx/no-shorthand-longhand-merge (strict: error, recommended: warn), flags a shorthand after one of its own longhands in one stylex.props() call or xstyle array. It reads same-file stylex.create() styles, dynamic styles, and local constants that pick a style. Two branches of one conditional never count as a merge. It reports nothing on this branch across core, lab, charts and richtext. On main it reports the five sites above.

Not changed: splitting base shorthands into longhands everywhere. Measured, that breaks callers: a caller's xstyle shorthand then loses to the component's new longhand in the published CSS. That moved Markdown list indents by 8px in two page templates.

Evidence

  • Same source tree, built twice, with only styleResolution differing. Computed values before → after:
    • List column gap: 8 / 0 → 8 / 8.
    • Stepper flex-shrink: 0 / 1 → 1 / 1.
    • PowerSearch inline padding (its exact styles): 4 / 0 → 0 / 0.
    • SideNav plain collapsed heading: unchanged in both builds (root's inline padding).
    • DiffViewer marker: 4 / 8 in both builds → unchanged.
  • Fixture screenshots at 1280 and 390 px, light and dark: identical before and after in both builds.
  • All 58 page templates in both builds, before and after: no template moves.
  • The rule's own test passes. Seeding a valid case with a shorthand after its longhand makes the test fail.
  • vitest for List, Stepper, SideNav, PowerSearch and DiffViewer passes.

Scope

Components: List, Stepper, PowerSearch, SideNav, DiffViewer (lab); lint plugin

  • 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

  • node internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs
  • eslint with the rule over packages/{core,lab,charts,richtext}/src: 0 findings (5 on main).
  • vitest run packages/core/src/{List,Stepper,SideNav} packages/core/src/PowerSearch/PowerSearch.test.tsx packages/lab/src/DiffViewer
  • Chromium: a fixture with the five components and all page templates, each built with both styleResolution options, before and after.

@vercel

vercel Bot commented Nov 17, 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 Nov 17, 2026 1:13pm UTC

Request Review

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

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 1:27 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · d2929ad

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

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

Changes requested. The new rule and the List, Stepper, PowerSearch and DiffViewer edits work: the rule finds the five sites on main, it finds none on this branch, and the component tests pass. Two claims need to match what the change does:

  • SideNavHeading.tsx:95-96 shrinks a collapsed SideNav heading that has an icon but no headingHref or menu from 40px to 32px and moves its icon 4px to the centre, in Storybook and in the published CSS alike, which the description calls no visible change and the changeset leaves out, so either keep the old rendering or announce the centring and get it decided.
  • The changeset says three components "now look the same in Storybook and in the published CSS" (line 5), but at the base the ordered List with dividers, the vertical on-track Stepper and the PowerSearch sheet trigger with tokens already rendered pixel-identical in both builds, so reword the release note and the description to say that only computed values change.

Two optional notes are inline: the rule's local constants are matched by name across the whole file, and the README's "the later style wins" does not hold in Storybook for paddingInline after its own longhands.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Storybook compiles StyleX with application-order: verified (Storybook main and Vite configs).
  • The published build uses property-specificity: verified (Core's Babel config sets no option; StyleX 0.19.1 defaults to it).
  • A shorthand before its longhand resolves the same in both builds: verified.
  • A shorthand after its longhand resolves differently: partly false; for paddingInline after its own longhands, the longhand wins in both builds.
  • Three components looked different in Storybook and in the published CSS: false; computed values differed, but frames match at the base.
  • After the change each listed state has one computed value in both builds: verified.
  • An ordered List with dividers keeps its number-to-text gap: verified; the published gap was already 8px.
  • The Stepper connector can shrink: misleading; flex-shrink is now 1 everywhere, but its zero basis leaves its size unchanged.
  • The PowerSearch sheet trigger with tokens has no padding: verified for computed values; the button is empty, so nothing changes on screen.
  • The SideNavHeading site did not diverge: verified.
  • The SideNavHeading site has no visible change: false; the collapsed icon-only heading narrows and its icon moves 4px.
  • The DiffViewer marker style never applied and its removal changes nothing: verified from the StyleX expansion and the same pattern measured on SideNavHeading.
  • The rule reads same-file styles, dynamic styles and local constants, and ignores opposite branches: verified (test cases and code).
  • The rule reports nothing on this branch and five sites on main: verified.
  • The rule test passes, and a seeded bad case fails it: verified.
  • The component tests pass: verified (22 files, 823 tests).
  • Splitting base shorthands would break callers: not checked (describes an alternative this change does not ship).
  • All page templates are unchanged: not checked.
  • Fixture screenshots match apart from the listed values: partly false; the collapsed SideNav heading frame changes.
  • No new visual representation is hidden under the fix label: false (SideNavHeading).
  • Public text carries no internal context: verified.
  • The new lint rule flags the pattern: verified.

Files:

  • .changeset/shorthand-after-longhand.md: release-note claims (both findings).
  • eslint.config.js: clear.
  • internal/eslint-plugin-astryx/README.md: optional wording note.
  • internal/eslint-plugin-astryx/index.js: clear.
  • internal/eslint-plugin-astryx/no-shorthand-longhand-merge.js: optional scope note.
  • internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs: clear.
  • packages/core/src/List/List.tsx: clear.
  • packages/core/src/PowerSearch/PowerSearch.tsx: clear.
  • packages/core/src/SideNav/SideNavHeading.tsx: unannounced visible change (first finding).
  • packages/core/src/Stepper/Step.tsx: clear.
  • packages/lab/src/DiffViewer/DiffViewer.tsx: clear.

Automated review (maintainer link)

Comment thread .changeset/shorthand-after-longhand.md Resolved
VariableDeclarator(node) {
if (node.id.type !== 'Identifier' || !node.init) return;
if (!isStylexCall(node.init, 'create')) {
locals.set(node.id.name, node.init);

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: locals is keyed by name for the whole file. Two components in one file that each declare, say, const side = … resolve to whichever is declared last. Resolving the identifier through its scope (context.sourceCode.getScope(node)) keeps each merge to its own constant.

Comment thread internal/eslint-plugin-astryx/README.md Resolved

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

Approved pending CI: the CI run on this head found no room under the CI ceiling ("CI is full"), so its jobs need a re-run before merge.

Both earlier change requests are fixed: the collapsed SideNavHeading with only an icon keeps its 40px box and icon position in Storybook and in the published resolution, and the changeset now says that only computed values change. The rule reports the five sites on main and none on this branch, and the List, Stepper, SideNav, PowerSearch and DiffViewer tests pass.

Two optional notes: the new comment at SideNavHeading.tsx:97 could keep only its reason (inline), and the rule still matches local constants by name across the whole file (the open thread on its line 261).

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none

Claims:

  • The release note's three styles now set longhands instead of a later shorthand: verified (List.tsx:286, Step.tsx:839-843, PowerSearch.tsx:262-267).
  • Each of those states had two computed values and now has one: verified (List column gap 0px/8px to 8px/8px, Stepper flex-shrink 1/0 to 1/1, PowerSearch inline padding 0px/4px to 0px/0px).
  • Nothing changes on screen in either build: verified (base and head frames pixel-identical in both resolutions).
  • A new lint rule flags the pattern: verified (rule test; five findings on main, none on this branch).
  • The three states differed in computed style between Storybook and the published CSS, as the table gives: verified.
  • They rendered the same in both builds at the base: verified.
  • Storybook compiles with application-order: verified (Storybook main and Vite configs).
  • The published build uses property-specificity: verified (Core's Babel config sets no option; StyleX 0.19.1 defaults to it).
  • A shorthand before its longhand resolves the same in both builds: verified.
  • A shorthand after its longhand resolves differently: verified, with the exception the description names (an inline-padding shorthand after its own longhands applies in neither build).
  • The later style now sets the same properties, so it wins in every build, matching what Storybook showed: verified (for List, the base list style sets the gap shorthand and the divider style now sets the row gap).
  • The List column gap between number and text stays: verified (8px in both builds; an unordered divided list now computes a 2px column gap that its one-column layout does not use).
  • The plain collapsed SideNav heading keeps its 40px width and icon position, and the other collapsed forms are unchanged: verified (fixture in both builds, base and head).
  • The DiffViewer marker style never applied and removing it changes nothing: verified (StyleX expansion and the same pattern measured on SideNavHeading).
  • The rule is an error in strict lint and a warning in recommended lint: verified (plugin index).
  • The rule reads same-file styles, dynamic styles and local constants, and two branches of one conditional never merge: verified (tests and code).
  • The rule reports nothing on this branch across core, lab, charts and richtext, and five sites on main: verified.
  • The rule test passes, and seeding a bad case fails it: verified.
  • The component tests pass: verified (22 files, 823 tests).
  • Splitting base shorthands into longhands would break callers: verified in mechanism (an in-package caller such as Markdown, which passes its own styles to List, shares the component's layer, where a longhand beats a shorthand); the 8px figure was not reproduced, since the alternative is not shipped.
  • Fixture screenshots match before and after at desktop and phone widths, light and dark, in both builds: verified (1280px and 390px, light and dark, base and head frames pixel-identical in both resolutions).
  • No page template moves: verified from the styles (each computed change is inert in its own layout, and no template overrides a divided List's layout); the templates were not rendered.
  • No new public API, visual representation, default or interaction is hidden under the fix label: verified (API surface unchanged; frames identical).
  • Public text carries no internal context: verified.

Files:

  • .changeset/shorthand-after-longhand.md: clear.
  • eslint.config.js: clear.
  • internal/eslint-plugin-astryx/README.md: clear.
  • internal/eslint-plugin-astryx/index.js: clear.
  • internal/eslint-plugin-astryx/no-shorthand-longhand-merge.js: optional note (local constants matched by name across the file).
  • internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs: clear.
  • packages/core/src/List/List.tsx: clear.
  • packages/core/src/PowerSearch/PowerSearch.tsx: clear.
  • packages/core/src/SideNav/SideNavHeading.tsx: optional comment wording note.
  • packages/core/src/Stepper/Step.tsx: clear.
  • packages/lab/src/DiffViewer/DiffViewer.tsx: clear.

Automated review (maintainer link)

justifyContent: 'center',
paddingInline: 0,
},
// The plain collapsed heading keeps root's inline padding and only centres.

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: this comment restates what rootCollapsedCentered sets and leaves out why the padding has to stay. A version that keeps only the reason: // Keep root's inline padding. Without it, the plain heading narrows and its icon moves.

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

Approved pending CI: the CI run on this head found no room under the CI ceiling ("CI is full"), so its jobs need a re-run before merge.

The only new commit reformats the rule file with Prettier, and its code is unchanged. The rule still reports the five sites on main and none on this branch, the List, Stepper, SideNav, PowerSearch and DiffViewer tests pass, and those components render the same before and after, in Storybook and in the published CSS.

Two optional notes stay open: the comment at SideNavHeading.tsx:97 could keep only its reason, and the rule matches local constants by name across the whole file (its line 284).

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none

Claims:

  • The release note's three styles now set longhands instead of a later shorthand: verified (List.tsx:286, Step.tsx:840-842, PowerSearch.tsx:266-267).
  • Each of those states had two computed values and now has one: verified (List column gap 0px/8px to 8px/8px, Stepper flex-shrink 1/0 to 1/1, PowerSearch inline padding 0px/4px to 0px/0px).
  • Nothing changes on screen in either build: verified (base and head frames pixel-identical in both resolutions).
  • A new lint rule flags the pattern: verified (rule test; five findings on main, none on this branch).
  • The three states differed in computed style between Storybook and the published CSS as the table gives, and rendered the same at the base: verified.
  • Storybook compiles with application-order and the published build uses property-specificity: verified (Storybook main and Vite configs; Core's Babel config sets no option, and StyleX 0.19.1 defaults to property-specificity).
  • A shorthand before its longhand resolves the same in both builds, and one after it does not: verified, with the exception the description names (an inline-padding shorthand after its own longhands applies in neither build).
  • The later style now sets the same properties, so it wins in every build and matches what Storybook showed: verified.
  • The List column gap between number and text stays: verified (8px in both builds; an unordered divided list now computes a 2px column gap that its one-column layout does not use).
  • The plain collapsed SideNav heading keeps its 40px width and icon position, and the other collapsed forms are unchanged: verified (fixture in both builds, base and head).
  • The DiffViewer marker style never applied, so removing it changes nothing: verified (StyleX's expansion of the inline-padding shorthand; the same pattern measured on SideNavHeading).
  • The rule is an error in strict lint and a warning in recommended lint: verified (plugin index; the root config adds it for Lab and charts).
  • The rule reads same-file styles, dynamic styles and local constants, and two branches of one conditional never merge: verified (tests and code).
  • The rule reports nothing on this branch across core, lab, charts and richtext, and five sites on main: verified.
  • The rule test passes, and seeding a bad case into its valid list fails it: verified.
  • The List, Stepper, SideNav, PowerSearch and DiffViewer tests pass: verified (22 files, 823 tests).
  • Splitting base shorthands into longhands would break callers: verified in mechanism; the 8px figure was not reproduced, since that alternative is not shipped.
  • The same tree built twice with only the resolution differing gives the before and after values listed: verified.
  • Fixture screenshots match before and after in both builds: verified at 1280px in light; 390px and dark were verified at the previous revision, and the component code is unchanged since.
  • No page template moves: verified from the styles; the templates were not rendered.
  • No new public API, visual representation, default or interaction is hidden under the fix label: verified (API surface unchanged; frames identical).
  • Public text carries no internal context: verified.

Files:

  • .changeset/shorthand-after-longhand.md: clear.
  • eslint.config.js: clear.
  • internal/eslint-plugin-astryx/README.md: clear.
  • internal/eslint-plugin-astryx/index.js: clear.
  • internal/eslint-plugin-astryx/no-shorthand-longhand-merge.js: optional note (local constants matched by name across the file); the new commit only reformats it.
  • internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs: clear.
  • packages/core/src/List/List.tsx: clear.
  • packages/core/src/PowerSearch/PowerSearch.tsx: clear.
  • packages/core/src/SideNav/SideNavHeading.tsx: optional comment wording note.
  • packages/core/src/Stepper/Step.tsx: clear.
  • packages/lab/src/DiffViewer/DiffViewer.tsx: clear.

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 18, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12252 docs(cli): agent docs name the prop names that differ from other libraries
  Author: Joey Farina <[email protected]>
- #12154 fix(core): a numeric typography weight builds through an extended base's adaptation rules
  Author: Joey <[email protected]>
- #12092 fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone
  Author: Joey Farina <[email protected]>
- #12316 fix(core): a shorthand never follows its own longhand in one style merge
  Author: josephfarina <[email protected]>
- #12357 fix(core): a Table stays the scroll region when a host scrolls every table's parent
  Author: Joey Farina <[email protected]>
- #12349 fix(core): end a mouse drag a sandboxed frame never saw released
  Author: josephfarina <[email protected]>
- #12425 fix(cli): use a stored doc parse only with the zod release that made it
  Author: Joey <[email protected]>
- #12396 fix(AppShell): with the standard width points, a server-rendered shell hides its inline side nav on a phone before its script runs
  Author: Joey <[email protected]>
- #12438 fix(charts): end dots draw whole and a thinned axis keeps its last label
  Author: Joey Farina <[email protected]>
- #12448 fix(cli): upgrade outside a project names the project, not --from
  Author: Joey Farina <[email protected]>
- #12459 fix(templates): the dashboard scorecard fits a phone screen
  Author: Joey Farina <[email protected]>
- #12428 fix(core): Field labels draw in a bolder face than their description
  Author: Joey Farina <[email protected]>
- #12435 fix(theme-matcha): dark menus, popovers and muted fills take the theme's deep gray neutral
  Author: Joey <[email protected]>
- #12432 fix(templates): dashboard chart labels show whole instead of clipped by the chart edge
  Author: Joey Farina <[email protected]>
- #12441 fix(cli): mark icon-set generated calls pure so apps drop unused icons
  Author: Joey Farina <[email protected]>
- #12472 fix(MetadataListItem): a value breaks only a word longer than its line
  Author: Joey <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12718.

@github-actions
github-actions Bot deleted the rl-17c-shorthand branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — d2929ad2 Deployed Nov 17, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant