Skip to content

refactor(core): tidy ComplexSelector trigger focus ring and icon slot - #5114

Merged
cixzhang merged 2 commits into
mainfrom
complexselector-nits
Aug 17, 2026
Merged

cixzhang merged 2 commits into
mainfrom
complexselector-nits

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up nits from the review on #4769, split out as agreed at merge time.

This is a readability refactor, not a fix — it is behavior-preserving. Both edits remove a condition that never did any work. Nothing about what the component renders, or when, changes. There is no changeset for that reason.

Focus ring. variant === 'input' and variant === 'ghost' both applied focusOutlineStyles.focusWithin, and ComplexSelectorVariant is exactly those two — so the condition was always true. Applied unconditionally, and restored the note (dropped in #4769) explaining that the ring lives on the wrapper but must stay a keyboard ring, i.e. :has(:focus-visible) rather than :focus-within. styles.triggerGhost sets no outline* longhands, so the reordering does not change what wins.

Start icon. Guarded with the shared isRenderable helper instead of raw truthiness. isRenderable takes a ReactNode and startIcon is ReactNode | IconType, so the check is on the resolved slot node — cast-free, and no change to the public isRenderable signature.

Behavior verification

The rendered DOM was compared before and after across the whole startIcon input space — 15 inputs, identical DOM on every one. That includes each way the slot can be empty, which is where a truthiness-to-isRenderable swap would show up if it were going to: undefined, null, false, 0, '', an empty fragment, an empty array, and a component that returns null.

0 is the interesting one, and it is unchanged and out of scope: startIcon={0} paints a literal "0" in the trigger, both before and after. Before, 0 && renderIconSlot(0) evaluated to 0; now renderIconSlot(0) returns 0 and isRenderable(0) is true, so React renders the same text node. That is a pre-existing wart in the slot contract, not something this PR introduces or repairs — fixing it means deciding what an isRenderable slot should do with a stray number, which belongs in its own change.

Test plan

  • Merged current main in; pnpm vitest run packages/core/src/ComplexSelector packages/core/src/Selector packages/core/src/MultiSelector — 238 passed
  • tsc --noEmit on packages/core, eslint on the component — clean
  • Keyboard vs pointer focus ring checked in Chromium on both variants

Follow-up nits from the #4769 review:

- Both variant branches applied focusOutlineStyles.focusWithin, so the
  condition was always true; apply it unconditionally and restore the
  note explaining why the ring is :has(:focus-visible).
- Guard the start icon with isRenderable, the shared slot-content check.
@vercel

vercel Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 17, 2026 1:37am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 16, 2026
@github-actions

github-actions Bot commented Aug 16, 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 450 -
Complexity N/A Very High (42) -

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

github-actions Bot added a commit that referenced this pull request Aug 16, 2026
@cixzhang
cixzhang marked this pull request as ready for review August 17, 2026 01:34
@cixzhang
cixzhang merged commit 68b10b6 into main Aug 17, 2026
21 of 22 checks passed
github-actions Bot added a commit that referenced this pull request Aug 17, 2026
@github-actions
github-actions Bot deleted the complexselector-nits branch August 17, 2026 06:14

This branch was successfully deployed

1 active deployment
Preview — 626ff28e Deployed Aug 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant