Skip to content

fix(selector): drop the shared trigger-icon wrapper - #4846

Merged
cixzhang merged 1 commit into
mainfrom
fix/selector-trigger-icon-wrapper
Aug 10, 2026
Merged

cixzhang merged 1 commit into
mainfrom
fix/selector-trigger-icon-wrapper

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Why

Follow-up to #4838. That PR moved each rotation onto the icon it belongs to, but in the three selectors the icon still sat inside a shared wrapper span:

<span triggerIcon>                    ← 16px box + colour, NO theme target
  status branch  → <Icon>             ← no target of its own
  chevron branch → <Icon …indicator-icon>
</span>

Two problems in one node. A theme could restyle the chevron but not the box around it, and the status glyph and the disclosure chevron — two unrelated affordances — shared a parent purely because they happen to occupy the same 16px.

The wrapper turned out to be entirely redundant:

wrapper style <Icon> already provides
width/height: 16 size="sm" → 1rem
color: --color-icon-secondary color="secondary" → the same token
alignItems/justifyContent: center nothing to centre once box == glyph
display: flex Icon's span is already inline-flex
flexShrink: 0 the one real leftover → xstyle

The colour was already dead on the status branch — that <Icon> passes STATUS_ICON_COLOR_MAP[status.type] and overrides it. It existed only so the chevron could say color="inherit".

What

Each trigger <Icon> now carries its own box, colour, rotation and theme target; triggerIcon collapses to flexShrink: 0. Selector, MultiSelector and ComplexSelector were byte-identical here, and all three are converted.

The chevron changes color="inherit" → color="secondary" — the same --color-icon-secondary it inherited from the wrapper, now set on the element a theme can reach.

No new theme targets. The status icon still has none of its own; making it themeable is a separate decision, noted below.

The status tooltip's <button> stays. It carries aria-label, onClick and the tooltip ref — behaviour, not styling. IconButton is not a fit: it is a Button, so it brings padding and a hit target that a bare inline affordance inside another control's trigger row should not have. And the button is not in the way — see the theme probe below.

Visual verification

Two Storybook servers (this branch vs main at 4b1fef5), Playwright at 2×. Both the rendered pixels and each icon's measured box, position and computed colour:

Story differing px geometry + colour
Selector/Default 0 / 201,600 identical
Selector/WithStatus 0 / 588,800 identical
Selector/StatusVariantComparison 0 / 1,041,600 identical
Selector/ClearableWithStatus 0 / 368,000 identical
Selector/SizeVariants 0 / 552,000 identical
Selector/GhostVariant 0 / 235,200 identical
MultiSelector/Default 0 / 257,600 identical
MultiSelector/Status 0 / 552,000 identical
ComplexSelector/FruitRipenessGrid 0 / 416,000 identical

Selector/StatusVariantComparison — before / after, 0 differing pixels:

status before
status after

Selector/SizeVariants, after — the 16px box is unchanged at every trigger size:

sizes

Theme probe — the point of the change

Injecting the kind of same-element rule defineTheme emits, into @layer astryx-theme, and measuring what lands:

@layer astryx-theme {
  .astryx-selector-indicator-icon { color: magenta; }
  .astryx-icon { outline: 1px solid green; }
}
icon inside the tooltip <button>? colour before colour after outline
status glyph yes rgb(165,12,37) unchanged applied
chevron (selector-indicator-icon) no rgb(115,115,115) rgb(255,0,255) applied
detached field-status-icon no rgb(137,0,26) unchanged applied

Every trigger icon is reachable, including the one inside the button — so the wrapper <button> does not need adjusting for the icon to be themed. The chevron's own target overrides its colour, which is the seam this PR opens.

theme probe

Testing

  • pnpm -F @astryxdesign/core typecheck · pnpm -F @astryxdesign/core lint — 0 errors (12 warnings, all pre-existing no-style-only-wrapper reports on main)
  • pnpm exec vitest run --project ui packages/core/src/Selector packages/core/src/MultiSelector packages/core/src/ComplexSelector — 175 passing
  • Selector's and MultiSelector's "byte-identical default icon" guards now compare against color="secondary" instead of color="inherit", matching where the colour moved. Same guard, same intent: no colour or size drift versus a standalone icon.

Also here

Three unused themeProps imports left behind on main by #4838 (the Table plugins whose wrappers it removed). One line each; they were failing lint on this branch.

Noted, not done

The on-field status icon has no theme target — it renders as a bare astryx-icon, while the detached one has astryx-field-status-icon. So a theme cannot restyle just the error/warning glyph in a Selector trigger. That is a new target rather than a consolidation, so it is deliberately not in this PR.

@cixzhang
cixzhang requested a review from imdreamrunner as a code owner August 9, 2026 17:03
@vercel

vercel Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
astryx Ignored Ignored Aug 9, 2026 5:16pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 9, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

ComplexSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 348 -
Complexity N/A Very High (31) -
MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1449 -
Complexity N/A Very High (175) -
Selector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1462 -
Complexity N/A Very High (138) -
Table (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1936 -
Complexity N/A Very High (112) -

Bundle Size Summary

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

Accessibility Audit

Status: No accessibility violations detected.


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

@cixzhang
cixzhang force-pushed the fix/selector-trigger-icon-wrapper branch from 4395448 to e7e0f44 Compare August 9, 2026 17:16
github-actions Bot added a commit that referenced this pull request Aug 9, 2026
github-actions Bot added a commit that referenced this pull request Aug 9, 2026
@cixzhang
cixzhang merged commit 8a9073a into main Aug 10, 2026
19 checks passed
@github-actions
github-actions Bot deleted the fix/selector-trigger-icon-wrapper branch August 11, 2026 06:22
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