Repository navigation
refactor(core): migrate style-only wrappers onto component xstyle - #4775
Merged
Merged
Conversation
…style
The <span {...stylex.props(rtlStyles.mirror)}> wrappers around directional
chevrons exist only to carry the mirror transform. Icon extends BaseProps and
merges xstyle into the same span it already renders, so the style lands on the
same element and one DOM node goes away. Pagination's prev/next carets already
use this shape (#4752); this brings first/last, Carousel, Lightbox and the
Table row-expansion menu icon in line.
Sites: Carousel x2, Lightbox x2, Pagination x2, Table/rowExpansion x1.
Each wrapper here carried only positioning/spacing for the single Astryx component inside it, so the styles move onto that component's own root: - Lightbox close/prev/next: absolute placement onto IconButton's xstyle. navButton switches transform: translateY(-50%) to the individual translate property, because on the Button root a transform replaces the Button's own transform rules and kills its scale(0.98) press feedback; translate composes with them, which is what the wrapper+button pair did before. - Pagination page-size Selector: the wrapper set width, so it becomes the documented width prop. Selector's xstyle targets the trigger box, not the field root, so xstyle would have sized the wrong element. - MobileNav header Heading, Switch FieldStatus, TopNav drawer Divider, TopNavMegaMenu Grid: straight move onto xstyle. Measured with Playwright against Storybook: rendered geometry is unchanged except where the wrapper was actively mis-centering the icon — Lightbox prev/next chevrons and Pagination first/last chevrons were 2.5-3px off the button's vertical center (same defect #4752 fixed for prev/next) and are now centered.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
github-actions
Bot
requested review from
cvkxx,
ernestt,
kentonquatman and
rubyycheung
August 7, 2026 00:47
cixzhang
marked this pull request as ready for review
August 7, 2026 01:04
cixzhang
requested review from
humbertovirtudes and
imdreamrunner
as code owners
August 7, 2026 01:04
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsCarousel (@astryxdesign/core) · View in Storybook
Lightbox (@astryxdesign/core) · View in Storybook
MobileNav (@astryxdesign/core) · View in Storybook
Pagination (@astryxdesign/core) · View in Storybook
Switch (@astryxdesign/core) · View in Storybook
Table (@astryxdesign/core) · View in Storybook
TopNav (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Style-only wrappers are the root cause of wrapper-shaped theme targets: a
<div>/<span>that exists only to carry styles is often the only element in the subtree with styles on it, so that's what people end up theming — a node the component contract never promised. Theming targets should attach to the component that paints; layout is not a theme seam.This is the follow-up #4758 (
feat(lint): flag div/span wrappers that only style an Astryx component) names in its own description: migrate the pre-existing sites so the rule can eventually go strict. Each site moves real styles onto a component root, which is why it wanted its own visual check rather than riding along with the rule.Related: #4752, which fixed an off-center pagination caret caused by exactly one of these wrappers.
The count is 23, not 25 — #4758's description should be corrected
Running the rule against
origin/main(cherry-picking #4758's plugin locally, not included in this diff) reports 23 violations in shipped code, in 10 files. There are 3 more in*.test.tsx, whicheslint.config.jsdeliberately turns the rule off for — 23 + 3 = 26, so the "25" looks like an older count taken before that test exclusion settled. Nopackages/corefile flagged here changed between #4758's merge-base andmain, so this is not drift since the branch was cut.What moved (15 of 23)
Carousel.tsx:563,588rtlStyles.mirror<Icon xstyle={rtlStyles.mirror}>Lightbox.tsx:615,682rtlStyles.mirror<Icon xstyle={rtlStyles.mirror}>Pagination.tsx:815,868rtlStyles.mirror<Icon xstyle={rtlStyles.mirror}>(matches what #4752 already did for prev/next)useTableRowExpansion.tsx:601rtlStyles.mirror<Icon xstyle={rtlStyles.mirror}>Lightbox.tsx:598position:absolute,top,insetInlineEnd,zIndex<IconButton xstyle={[styles.closeButton, styles.controlButton]}>Lightbox.tsx:612,679position:absolute,top:50%,transform:translateY(-50%), inset,zIndex<IconButton xstyle={[styles.navButton, styles.navPrev|navNext, styles.controlButton]}>—transformbecame the individualtranslateproperty, see belowMobileNav.tsx:456marginInlineStart<Heading xstyle={styles.headerText}>Switch.tsx:646marginTop<FieldStatus xstyle={styles.statusGap}>TopNav.tsx:246marginBlock<Divider xstyle={styles.drawerDivider}>TopNavMegaMenu.tsx:496flexGrow/flexShrink/flexBasis/minWidth<Grid xstyle={styles.menuWrapper}>Pagination.tsx:794width: 80<Selector width={80}>— thewidthprop, notxstyle, see belowTwo of these are not a plain relocation, and both are because the target component already owns the property:
Lightboxnav buttons —transform: translateY(-50%)on theButtonroot collides with Button's owntransformrules. Measured: withtransforminxstyle, the pressed button reportsmatrix(1,0,0,1,0,-16)— Button'sscale(0.98)press feedback silently stops firing. Switching to the individualtranslate: '0 -50%'property composes instead of replacing: pressed reportstranslate: 0px -50%+transform: matrix(0.98,0,0,0.98,0,0), i.e. exactly the wrapper-translates-button-scales composition that existed before. Disabled state (transform: none) also behaves.Paginationpage-size Selector —Selector'sxstylelands on the trigger box, not the field root (Selector.tsx:1193vs the<Field>it returns at the bottom), which is documented on thewidthprop itself.widthis the API that sizes the field, sowidth={80}reproduces the wrapper exactly.Visual evidence
Playwright + Chromium at DPR 2 against local Storybook, before/after per component, full-image pixel diff plus computed geometry. Images and geometry dumps:
~/wrapper-migration/*.png(also/tmp/wrapper-migration/).core-carousel--default, LTR + forced RTLcore-pagination--with-page-size-selectorcore-switch--status-variationscore-appshell--top-nav-with-side-nav@500px, drawer openmargin: 8px 0itselfcore-mobilenav--default, drawer openmargin-left: 4pxcore-topnavmenu--mega-menu, panel opencore-lightbox--galleryLTR / RTL / last-item (disabled next)y 679-711inside a buttony 668-732(centre 695 vs 700); after, centred exactly. Nav-button positions are otherwise identical, RTL mirroring unchanged.core-pagination--input-variantLTR / RTLy=38→y=44, matching prev/next which were already at 44). This is the same defect #4752 fixed for prev/next — the wrapper was the cause.core-tablerowexpansion--inherited-columns, context menu openSo: 11 of the 13 captured states are pixel-identical, and the two that differ are pre-existing mis-centering that this PR fixes.
Left unmigrated (8) — both are rule findings, not cowardice
7 ×
PowerSearchEditPopover.tsx(312, 324, 337, 555, 740, 799, 811) — blocked,xstylereaches the wrong element.Six of these wrap a
<Selector>in a flex sizing box (flexGrow/flexShrink/minWidth, orwidth: 200/180). BecauseSelectorputsxstyleon its trigger container and returns a<Field>root, moving those styles toxstylesizes the box inside the field instead of the field itself. Measured in a scratch story: field is 472px wide with the wrapper, 85px withxstyle={{flexGrow:1,minWidth:0}}(theflexGrowlands two levels down, on the trigger). That's a severe regression, so they stay. Unblocking them needs a decision on whetherSelector'sxstyleshould target the field root — public API, maintainer's call, and adjacent to #4528.The seventh (337) wraps
PowerSearchValueEditor, which is not aBasePropscomponent at all — it takes noxstyle/className/styleand just returns one ofTextInput/Typeahead/Tokenizer/NumberInput. The rule flagged it because it is imported relatively, and the defaultcomponentSourcesassumes every relative import takesxstyle. Rule bug: over-flag.1 ×
ChatLayoutScrollButton.tsx:133— rule over-flag, the wrapper is a clipping container.That
<div>is the pill:overflow: hidden+ animatedmax-width(32px collapsed → 200px expanded) around a ghost Button that is deliberately wider than the pill. I implemented the migration, measured it, and reverted: with the styles on the Button, the collapsed chevron sits 4px left of the circle's centre (button width 145.9px→32px, icon centre 250px→246px against a 250px circle centre), because the icon is no longer centred by clipping an over-wide button. The rule's structural exemptions coverdisplay, flex/grid container props,gapandpadding, but a wrapper whose job isoverflow+max-widthclipping is doing layout work just as much. Suggested rule fix: treatoverflow,max-width/max-heightandcontainas structural.Side finding while I had it apart: that same
overflow: hiddenclips the Button's:focus-visiblering today (offset 3px, pill is exactly the button's height) — a latent a11y issue inChatLayoutScrollButtonworth its own issue, independent of this PR.Rule tier: not flipping to
errorhereDeliberately not flipping
@astryx/no-style-only-wrappertoerrorin the strict tier, for two reasons:stylex.props(...)and every target is{...mergeProps(themeProps(...), stylex.props(...))}. That ~15-line fix should land before the tier flip, so the flip happens against the rule's real scope rather than its current partial one.Test plan
npx vitest runover Carousel, Lightbox, Pagination, MobileNav, Switch, TopNav, Table, Chat, Selector — 1030 passed (Table.perf500-row budget flaked once under load alongside Storybook; passes clean in isolation).tsc --noEmiton@astryxdesign/core— no new errors (two pre-existinglocales/pseudo.jsonmodule errors in i18n tests, present onmain).eslinton every changed file — clean; the 8 remainingno-style-only-wrapperwarnings are the sites listed above.node scripts/check-changesets.mjs✓, plus the pre-commit gate (check:sync, package boundaries, demo media, executable bits, CLI structure) on each commit.patch,@cixzhang— no API change, but consumer-visible DOM, and the reasoning forpatchover[breaking]is written into the changeset body.Refs #4758.
🤖 Drafted with agentcloud; every measurement above was taken on this branch.