Repository navigation
fix(Spinner): stop a narrow flex host compressing the spinner's box - #5484
Conversation
A flex item's default `flex-shrink: 1` let a host narrower than the spinner compress its box while the ring kept drawing at the size its own attributes ask for, and `overflow: hidden` on the box then clipped the ring the box exists to contain — silently, since nothing reports a clipped child. Measured in Chromium (Spinner size=xl, 36px box, in a 16px flex host): the box came out 16x36 around a 36px ring, 20px of it cut. With flex-shrink: 0 the box is 36x36 and the ring is whole; a spinner that does not fit now overflows visibly at the host instead. Every internal host that already fitted — Switch sm/md, CheckboxInput sm/md, all 14px around a 14px ring — is unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report
Modified ComponentsSpinner (@astryxdesign/core)
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression110 added · 0 removed. To accept these exact frames: Generated by PR Enrichment workflow | View full report |
There was a problem hiding this comment.
Thanks — flexShrink: 0 is the right invariant for Spinner's own box.
The browser-only bug still has no shipped regression: the unit suite cannot observe layout, and the visual gate has no narrow-host story. Could you add that story so the browser check owns the red→green behavior?
[Reviewed by Robohands]
… floor The box carried `overflow: hidden` from the canvas ring the component no longer draws. It clips nothing — the painted circle is inscribed in the box, so hiding and showing the overflow render byte-identical pixels at every size, every shade, the labelled case and every rotation angle (68/68 comparisons) — but a flex item whose overflow is not `visible` has an automatic minimum size of zero, which is what left this box with no floor under it. That is the mechanism behind the clipping this branch already fixed with `flex-shrink: 0`, and ordinary layouts reach it, not just a host narrower than the spinner outright: an `md` spinner beside a label in a 140px row rendered a 16px box around a 20px ring, and an `lg` spinner next to a `flex: 1 0 100px` sibling lost half of its ring. Removing the clip fixes every one of those cases on its own; `flex-shrink: 0` stays because it holds where the automatic minimum size does not, namely a host that sets `min-width: 0` on its items. The changeset said the internal hosts (a Switch thumb around an `sm` spinner) were what reproduced this. They are not, as the PR thread already corrected — it now describes the layouts that do.
The bug is only observable through layout, so the unit suite cannot hold it and the fix shipped with no regression of its own. This story renders the three hosts that reproduced it — a label beside the spinner in a 140px row, a sibling that keeps its width, and a host narrower than the spinner outright — so the browser check compares them shot for shot. The hosts are deliberately raw flex containers: what is under test is what an arbitrary consumer's layout does to the box, not what a layout component of ours does.
|
Story added — While building it I went back at the premise, and the fix moved: the cause is the The clip protects nothing: with the rotation frozen at four angles, Two things in the old description were wrong and are corrected:
Nothing else moves: every size × shade × the labelled case × an inline-in-text case, at four frozen rotation angles — 72 of 72 element screenshots byte-identical between a build of |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the narrow-host story closes my prior ask, and the root-cause correction holds. This is ready to approve.
[Reviewed by Robohands]
|
I merged current main and resolved the two mechanical Spinner overlaps by keeping both the new theming stories/vars and this PR's narrow-host story/flex invariant. Pushed |
|
The main refresh left the narrow-host story nested inside the themed-hairline story, which broke Storybook parsing. I restored the missing close, formatted both merged Spinner files, and pushed |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — re-approving at the new head; the main merge dismissed my earlier approve. Rechecked in Chromium against the themed ring: the fix holds and the hairline story improves.
[Reviewed by Robohands]
|
|
||
| [fix] Spinner: a narrow flex host no longer compresses the box and clips the ring (#5484) | ||
|
|
||
| The spinner's box carried `overflow: hidden` from the canvas ring it no longer draws. It clipped nothing — the painted circle is inscribed in the box, so hiding or showing the overflow renders the same pixels at every size and shade — but a flex item whose overflow is not `visible` has an automatic minimum size of zero. That left the box with no floor: a flex host narrower than the spinner compressed it while the ring kept drawing at the size its own attributes ask for, and the clip then cut the ring off at the box edge, silently, because a sliced ring still spins. |
There was a problem hiding this comment.
Not quite true since #5214: the themed hairline ring does change, for the better.
|
Merged latest main (17 commits behind) — which also regenerates the visual evidence, since the report from 27 Aug had expired to a 404 and Component suite re-run green on the merge. No source change in this push. |
|
/accept-visual |
|
Visual acceptance refused: copy the exact |
rubyycheung
left a comment
There was a problem hiding this comment.
The fix makes sense visually and technically: Spinner preserves its documented size in constrained flex layouts instead of rendering a clipped ring. The narrow-host story demonstrates the regression and the corrected behavior clearly.
|
/accept-visual 33343939641/1 110 added, 0 removed — new baselines for stories that had none, and no existing frame moved. The report covers the current head (02d99d5, a main merge with no source change), and |
|
Visual acceptance refused: only a repository maintainer may accept stable visual changes. |
|
@cixzhang @rubyycheung — this one needs a maintainer to run the acceptance; I cannot, and I should have checked that before trying rather than posting a refused command twice. The gate resolves Everything else is done: three approvals, 23 checks green, The exact command from the report: |
Summary
Split out of #5214 at review request — it is independent of the theming work and lands on its own merits.
A flex host narrower than the spinner compressed the spinner's box while the ring kept drawing at the size its own attributes ask for, and the box then clipped the ring it exists to contain. Nothing reported it, because a sliced ring still spins.
The cause is
overflow: hiddenon the box, carried over from the canvas ring this component no longer draws. A flex item whose overflow is notvisiblehas an automatic minimum size of zero, so the clip was what left the box with no floor under it — and then cut the ring off at the edge it had shrunk to. The clip itself protects nothing: the painted circle is inscribed in the box at every size and shade, so hiding and showing the overflow render byte-identical pixels.So the fix is a deletion plus the invariant:
overflow: hiddenis gone. With the overflow visible the automatic minimum size applies again, which floors the box at the ring's own size. This alone fixes every case below.flex-shrink: 0stays. It states the invariant directly rather than leaning on the automatic minimum size, which a host takes away again the moment it setsmin-width: 0on its items — a common enough flex idiom. A spinner that does not fit overflows its host visibly instead of being silently sliced.What reproduces it — measured in Chromium 149
Two builds of the same harness,
origin/mainand this branch.boxis therole="status"span;ringis the svg's own width;clippedis how much of the ring the box cut off.mdbeside a label in a 140px rowxlbeside a label in a 160px rowlgbeside aflex: 1 0 100pxsiblingxlin a 16px flex hostxlin a block host (control)The first three are ordinary layouts — a spinner beside a label, a spinner beside a sibling that will not give up its width — which is the part #5214's description got wrong and this one corrects. The internal hosts do not reproduce it and never did: a Switch thumb is 14px around a 14px spinner box, so there is nothing to compress.
Switchsm/md(on and off),CheckboxInputsm/mdandButtonsm/md/lgall measure a 14 × 14 box around a 14px ring with 0 clipped, onmainand on this branch alike.Nothing else moves
Every size × every shade × the labelled case × the inline-in-text case, at four frozen rotation angles: 72 of 72 element screenshots byte-identical between a build of
origin/mainand a build of this branch, and the box geometry and position identical to the hundredth of a pixel — including the inline case, where the box is baseline-aligned and removing a scroll container could plausibly have shifted it.That is also the evidence that the clip was dead: with the rotation frozen at 0°, 22.5°, 45° and 67.5°,
overflow: hiddenandoverflow: visiblerender the same pixels in all 68 comparisons.The story
Core/Spinner → NarrowFlexHostrenders the three reproducing hosts, so the browser check owns the red→green rather than the PR description owning it. The hosts are raw flex containers on purpose: what is under test is what an arbitrary consumer's layout does to the box.Test plan
pnpm build,pnpm lint:strict(0 errors, 80 warnings — the same 80origin/mainreports),pnpm -F @astryxdesign/core typecheck,pnpm exec vitest run packages/core/src/Spinner(33 passed).