Skip to content

fix(Stepper): simplify collapse and context APIs - #6097

Merged
imdreamrunner merged 1 commit into
mainfrom
stepper-pixel-min-width
Sep 7, 2026
Merged

imdreamrunner merged 1 commit into
mainfrom
stepper-pixel-min-width

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Restrict Stepper's horizontalOptions.minimumStepWidth to numeric pixel values.
  • Remove the CSS-length measurement element and its resize observer.
  • Change registerStep from a disabled boolean to an optional {getIsDisabled} options object, with Step supplying the getter.
  • Re-resolve compact navigation targets at activation so a getter change cannot select a newly disabled step from a stale render.
  • Use separate public and internal contexts: useStepperContext() receives exactly the supported runtime keys, while the built-in Step receives compact-layout coordination through useStepperInternalContext().
  • Keep previousActiveStep and registerStep on the public context while removing stepCount, isCompact, summarySlot, minimumStepWidth, and minStepWidthMeasureRef from StepperContextValue and useStepperContext at both type and runtime boundaries.

Public API

  • Owner: component:Stepper (authority: current)
  • Before → after: collapse thresholds accepted numbers or CSS-length strings and the public context exposed compact-layout implementation fields; thresholds now accept pixel numbers only, registration reads disabled state through an optional getter, and the five named implementation fields are private or removed at type and runtime boundaries.
  • Classification: breaking API simplification relative to v0.5.3.
  • Migration: replace CSS lengths such as '7rem' with their intended pixel number; replace registerStep(index, isDisabled) with registerStep(index, {getIsDisabled}) or omit the options; stop reading the removed context fields.

Testing

  • pnpm exec vitest run packages/core/src/Stepper/Stepper.test.tsx packages/core/src/Stepper/Stepper.public.test.ts — 95 tests passed
  • Runtime-key assertions cover horizontal and vertical public providers
  • pnpm -F @astryxdesign/core typecheck
  • pnpm lint:strict — 0 errors (repository baseline warnings only)
  • pnpm -F @astryxdesign/core build
  • pnpm check:knowledge
  • pnpm check:changesets

@imdreamrunner

Copy link
Copy Markdown
Contributor Author

/approve-spec 9aaf104

@vercel

vercel Bot commented Sep 7, 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 Sep 7, 2026 8:04pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 7, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Sep 7, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

That /approve-spec comment did not change spec-owner-approval: it did not name exactly one full 40-character commit SHA.

The gate only accepts the exact current head, so post this instead:

/approve-spec 9aaf104fe3f34d8798f85cd6f19d22024bddc8a1

A new commit invalidates the command, so repeat it after any push.

@github-actions

github-actions Bot commented Sep 7, 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

Stepper (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1603 -
Complexity N/A Very High (189) -

Bundle Size Summary

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

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Stepper - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/30 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

Status: No visual change across 2 compared shot(s).


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

@imdreamrunner
imdreamrunner marked this pull request as draft September 7, 2026 07:10
@imdreamrunner
imdreamrunner force-pushed the stepper-pixel-min-width branch from 9aaf104 to a1d38d5 Compare September 7, 2026 07:16
@imdreamrunner imdreamrunner changed the title fix(Stepper): use pixel-only collapse thresholds fix(Stepper): simplify collapse and context APIs Sep 7, 2026
@imdreamrunner

Copy link
Copy Markdown
Contributor Author

/approve-spec 9aaf104

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

That /approve-spec comment did not change spec-owner-approval: it named 9aaf104, which is not the current head.

The gate only accepts the exact current head, so post this instead:

/approve-spec a1d38d50c7684d1363a038e07c5397c3747e46ac

A new commit invalidates the command, so repeat it after any push.

github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@imdreamrunner

Copy link
Copy Markdown
Contributor Author

/approve-spec a1d38d5

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Sep 7, 2026
@imdreamrunner
imdreamrunner marked this pull request as ready for review September 7, 2026 08:43

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

Custom descendants using the new registration API can still send users to a disabled step. After getIsDisabled() changes, Next keeps the target captured during the Stepper’s last render: the probe selected step 2, then selected step 3 only after an unrelated parent render. Please make compact activation use the current registration state without requiring that rerender.

Also, the NarrowCollapse story still calls its numeric 64 example “4rem.”

[Reviewed by Robohands]

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Sep 7, 2026
@imdreamrunner
imdreamrunner force-pushed the stepper-pixel-min-width branch 2 times, most recently from 1f79767 to ac85d65 Compare September 7, 2026 15:52
@github-actions
github-actions Bot requested a review from cixzhang September 7, 2026 15:52

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

JavaScript consumers still receive stepCount, isCompact, and summarySlot from useStepperContext(), because the public hook returns the same runtime object as the internal hook. That leaves compact-layout implementation reachable despite the new contract and makes the cleanup incomplete. Please project a genuinely public value from useStepperContext() and add a runtime key assertion; keep useStepperInternalContext() for Step.

The stale registration target and “4rem” story label from the prior review are fixed.

[Reviewed by Robohands]

github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@imdreamrunner

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up. The two findings from the prior review are addressed on ac85d65be5c76aabeae8e3ca7fb7fde77935519d:

  • Compact Previous/Next now re-runs adjacentEnabledStep(delta) inside activation, so it reads the current getIsDisabled() values rather than navigating with a render-time target. The regression mutates a registered getter without a React rerender and verifies Next skips step 2 for step 3.
  • The NarrowCollapse story now labels the numeric example as 64px, not 4rem.

I also see the new runtime-surface finding: useStepperContext() is typed as the public subset but currently returns the wider provider object at runtime. I am pausing before changing that API behavior; the proposed follow-up is to project an exact public object in useStepperContext() and add a runtime key assertion, while leaving useStepperInternalContext() unchanged for the built-in Step.

@imdreamrunner
imdreamrunner force-pushed the stepper-pixel-min-width branch from ac85d65 to 67b7cb7 Compare September 7, 2026 20:01
@imdreamrunner

Copy link
Copy Markdown
Contributor Author

Addressed the runtime-surface follow-up in 67b7cb7d26367fdab113b98091ed5348cf919b45.

  • StepperContext now carries an exact StepperContextValue with only the eight supported public keys.
  • A separate StepperInternalContext carries stepCount, isCompact, and summarySlot; only useStepperInternalContext() (used by the built-in Step) reads it.
  • useStepperContext() now reads only the public provider, so JavaScript can no longer access the removed compact-layout fields.
  • Added an Object.keys(useStepperContext()) runtime assertion for both horizontal and vertical provider paths.

The prior findings remain fixed: activation re-reads getIsDisabled() without a rerender, and the story says 64px.

Validation: 95 focused tests pass; core typecheck, strict lint, core build, knowledge, and changeset checks pass. Independent focused review found no findings. Ready for Robohands re-review.

@imdreamrunner

Copy link
Copy Markdown
Contributor Author

/approve-spec 67b7cb7

@github-actions
github-actions Bot requested a review from cixzhang September 7, 2026 20:01
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Sep 7, 2026
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@imdreamrunner

Copy link
Copy Markdown
Contributor Author

All checks on exact head 67b7cb7d26367fdab113b98091ed5348cf919b45 are now green, including UI/node tests, build, lint, a11y, RTL, visual regression, and exact-head spec approval. The runtime key assertion passes in both horizontal and vertical orientations. @cixzhang re-review requested to clear the two superseded change requests.

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

Thanks, this resolves our stale registration, story label, and public runtime-context asks. The 447/448px boundary and focused tests are clean.

[Reviewed by Robohands]

@imdreamrunner
imdreamrunner merged commit 3750c46 into main Sep 7, 2026
30 checks passed
cixzhang added a commit that referenced this pull request Sep 7, 2026
Two commits, no conflicts, no file overlap with this branch's 22.

- #6120 gives AvatarGroupOverflow its own audit coverage and story;
- #6097 simplifies Stepper's collapse and context APIs.

Stepper renders an IconButton, which this branch binds to the button pattern, so
that coupling was checked rather than assumed: the incoming diff does not touch
the IconButton call, and nothing here changes component behaviour. Neither
commit touches internal/a11y-spec, the a11y stories, the workflows, or the
Playwright config.
@github-actions
github-actions Bot deleted the stepper-pixel-min-width branch September 8, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — 67b7cb7d Deployed Sep 7, 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.

2 participants