Repository navigation
Conversation
The text value label sits in the same flex row as the flex-growing track, so a label changing width while dragging resized the track and shifted the thumb under the pointer, retriggering value recalculation. Reserve the width of the widest formatted candidate (min/max/±step, doubled plus separator in range mode) in ch units with tabular-nums so the track size never moves. Also snap decimal steps to the precision of step/min so 0.2 + 0.1 emits 0.3 — not 0.30000000000000004 — in the visible label, aria-valuenow, and onChange. Fixes meta#4033
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| Slider · Storybook | 114.5 kB (+294 B) · 8.9 kB CSS (+17 B) | 2,488 (+41) |
Package size: @astryxdesign/core 7.57 MB packed (+1.3 kB); no new dependencies.
Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Current run: CI concluded failure; parts of this report may be missing.
Generated by PR Enrichment workflow | View full report
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for working on this fix. Sorry review took so long. You'll want to rebase this to resolve merge conflicts and I'm curious about your thoughts on the comment too.
| clamp(snapToStep(v, min, step), min, max), | ||
| ); | ||
| const widest = Math.max(...candidates.map(v => displayValue(v).length)); | ||
| const reservedCh = isRange ? widest * 2 + RANGE_SEPARATOR.length : widest; |
There was a problem hiding this comment.
Interesting. I hadn't seen ch before. https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/length#ch
Represents the width or, more precisely, the advance measure of the glyph 0 (zero, the Unicode character U+0030) in the element's font.
Reasonable to compute it like this when applying tabular numerical but I'm not sure if we want to change the design for numerics of the slider. In other places where we deal with text sizing we also use the strategy of applying hidden, inert text in the same location and leveraging the browser layout (I think we do this in tabs and toggle buttons where weight is modified based on state). Curious what you think about consolidating to this strategy and avoiding the typography update?
|
Checking in on the Slider fix: the current review still needs the branch refreshed and the drag-width comment answered. Would you like to continue, have us carry it, or close this for now? |
There was a problem hiding this comment.
Thanks for tackling the drag jitter and float artifacts — the common cases improve, but two supported cases still need fixing before this can land:
- Stepped values can be wrong in scientific notation: the precision helper returns only the exponent for values like
1.23e-7, so stepping twice emits2e-7instead of2.46e-7(also inaria-valuenow). Please account for the mantissa's decimal digits and add a test for that step. - The track can still resize with custom
formatValue: reservingchunits from the character counts of onlymin,max,min + step, andmax - stepmisses a widest label that occurs mid-range or uses wider glyphs. Please make sizing independent of sampled formatter output (the hidden inert sizing approach raised in review would address this), add a mid-range-widest test, and share your thoughts on keepingtabular-numsversus that approach.
The added tests for ordinary decimal steps and endpoint labels are a good base — extending them to these two cases should close the gaps.
[Automated review]
Resolved conflicts: - packages/core/src/Slider/Slider.tsx: getDecimalPrecision/snapToStep took upstream/main's version from meta#3897 (counts mantissa digits via toExponential) and dropped this branch's duplicate helper. The text-value width change merged cleanly. - packages/core/src/Slider/Slider.test.tsx: kept upstream's focus ring modality suite and this branch's width-stability suite. Dropped this branch's keyboard decimal-step test (duplicate of upstream's "emits exact decimal values for fractional steps on keyboard") and moved the pointer-position decimal test next to upstream's fractional-step tests, updating its comment for the thumb-inset travel math. The FormData test formatting now matches upstream exactly.
Address the review on meta#4050. F1 (exponent-notation steps lost mantissa digits): the merge from upstream/main already replaced this branch's getDecimalPrecision with the meta#3897 helper, which counts mantissa digits. Add a regression test that steps a controlled slider by 1.23e-7 twice and expects onChange 1.23e-7 then 2.46e-7 and aria-valuenow "2.46e-7". With the old helper it received [[1e-7], [2e-7]]. Drop the decimal-step sentence from the changeset, because meta#3897 already shipped it. F2/F3 (ch reservation missed mid-range and wide-glyph labels): drop tabular-nums and the ch min-width. Each value now renders in an inline-grid slot that stacks its visible text on an aria-hidden, visibility:hidden, zero-height sizer listing every reachable formatted label, one per line. The browser sizes the slot to the widest real label, as Tab's labelSizer and ToggleButton's widthReservation do. The sizer covers every step up to 200 steps (TEXT_VALUE_SIZER_LIMIT). Past that it takes evenly spaced steps plus the endpoints' neighbours. Range mode gives each value its own slot. Replace the ch-string tests with sizer tests (every label whatever the value, a mid-range-widest word formatter, `%` labels with no inline style, per-slot range sizers, decimal steps, and long-range sampling). All six failed before the change.
The lint-staged pre-commit hook ran eslint --fix and prettier --write over every file staged by the upstream/main merge (5cdd017), so the merge commit reformatted 32 files this PR never touches (docsite, cli templates, lab MobileTokenizer/Chart, vibe-test docs and others). One of them broke the build: prettier wrapped the `const info = ...` line in packages/core/src/i18n/getLocaleDirection.ts, which left the `@ts-expect-error` directive covering only `const info =` and made packages/core's tsc fail with TS2578/TS2339. This checks out each of those 32 files from the merged upstream commit (82fb22c) unchanged, committed with the hook disabled. After it, `git diff upstream/main` lists only the Slider sources and the changeset.
|
Sorry for the slow reply, @cixzhang. I'd like to keep carrying this. I've pushed up to e8731d4:
Still to do on my side: update the PR description, which still mentions the decimal-step fix and equal-width numerals. |
There was a problem hiding this comment.
Thanks for carrying this through the rebase and rework — this revision addresses both issues from the previous review:
- Track sizing no longer estimates width. The
chreservation andtabular-numsare gone. Each text value now stacks on a hidden, inert sizer listing the formatted labels of every reachable step (each range side sized separately), so the browser measures the real strings — including percent labels and a formatter whose widest label falls mid-range, both covered by new tests. - Exponent steps are covered. The branch now uses the snapping helper already on main, and a new test proves stepping by
1.23e-7twice emits and announces2.46e-7.
One limitation worth knowing about, already noted in the changeset: for ranges over 200 steps the sizer samples evenly spaced steps, so a custom formatter whose widest label falls only on an unsampled value could still widen the label there — no worse than before this fix. Ordinary and default-format ranges are covered.
Please also update the PR description before merging, as you noted: it still mentions equal-width numerals and the decimal-step fix, which are no longer part of this diff.
[Automated review]
# Conflicts: # packages/core/src/Slider/Slider.test.tsx
There was a problem hiding this comment.
Thanks for carrying this through: the track now keeps one length while the value changes, but approval needs an engineering owner to provide or identify the Slider spec for this presentation, because no current spec settles always reserving the widest reachable label (a shorter track at rest and a gap before the "–" in range mode). An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner. Whatever the decision, these changes are needed:
- Replace the six width tests, which read only the hidden sizer's text and still pass when the reserving grid is removed, with a check that sees layout, such as a stable visual-regression story that stacks text-display Sliders at a narrow and at the widest value.
- Update the PR description, which still claims equal-width numerals, a decimal-step fix that
mainalready ships, and six new tests (there are eight).
The branch also needs a refresh, since it conflicts with main in Slider.tsx, and the Slider owner's earlier change request needs their re-review; the inline notes on the new code comments are non-blocking.
[Automated review]
|
/approve-spec e429440 |
…rals The value label keeps its ch reservation on the visible label and drops tabular-nums, so the numerals keep the typography they have today. FR8 and the changeset drop 'digits of equal width'; the limit covers digits or other glyphs wider than 0. Co-authored-by: AKnassa <[email protected]>
|
/approve-spec c0a2309 |
kentonquatman
left a comment
There was a problem hiding this comment.
Thanks @AKnassa! Design looks good 👍
There was a problem hiding this comment.
Changes requested: the fix works (the Slider's track now keeps one length while a text value changes, and the new FR8 is approved for this head), but one line in the Slider record needs updating first.
- Miss: the Slider record's Compatibility and migration lines (
docs/specs/components/Slider/Slider.spec.md, lines 51–57) still say that every other released default and the default styling are unchanged, though FR8 shortens every text-display track at rest and moves a short value away from it, so please add FR8 there the way FR7 is listed (for example, "Text value width (FR8): ships as a patch[fix]; the resting track is shorter by the reserved box").
Approval will also need the July changes-requested review to be re-reviewed or dismissed by its reviewer, and CI to be re-run, because this head's run was refused for capacity before any check ran. Optional: FR8's Basis cell describes main's old behaviour in the past tense, and two comments in Slider.tsx (lines 612 and 1693–1695) could be shortened.
Claims and files checked
- The track stays the same size while dragging with the text display: verified for labels within the reservation (one 1,216 px track at 0, 50 and 100 in Chromium; on main it moves 16 px).
- A label that changes width squeezes the track and makes the thumb jitter: verified on main.
- The label reserves a minimum width in
chfor the longest of the end, neighbour and quarter-point labels and aligns its text to the end: verified inSlider.tsx. - The numerals keep today's typography: verified (no numeric font variant on main or this head).
- No hidden copy is rendered: verified.
- A format whose digits or other glyphs are wider than
0can still widen the label: verified from the mechanism (chis the width of0). - FR8 states the reservation and its limit, and its verification row names the new tests: verified.
- The decimal-precision fix is already on main and its tests were dropped here: verified.
- The hidden sizer is replaced by a CSS reservation on the visible label: verified.
- A formatter whose longest label falls between the samples is not covered: verified (seven samples).
- The owner's July review asked to keep the numerals and suggested a hidden sizer; the minimal-DOM rule adopted on 10-24 forbids a hidden twin: verified.
- The stills comparing main and this head: still pending in the description.
- The changeset says what changes for builders: verified, including the limit.
- Storybook steps show a still track: verified in Chromium with keyboard steps.
- The unit suite passes with 110 tests and the five width tests fail on main: verified.
- The Chromium track check measures one length at the narrowest and widest value and runs in pull request CI: verified that it passes on this head's Storybook build; CI itself did not run at this head.
- The knowledge check passes: verified.
- Writing rubric results R1 to R7: verified for the FR8 sentence; the Basis cell narrates the old behaviour (optional fix above).
- It fixes the reported drag issue: verified.
- Changeset: the track no longer resizes while dragging, with the wide-glyph limit: verified.
- Changeset: the value keeps the width of its longest likely label as
formatValuewrites it: verified as a character reservation. .changeset/slider-track-width-stability.md: clear.docs/specs/components/Slider/Slider.spec.md: Compatibility and migration lines miss FR8 (blocking); Basis tense (optional).packages/core/src/Slider/Slider.tsx: clear; two optional comment edits.packages/core/src/Slider/Slider.test.tsx: clear.packages/core/src/Slider/__tests__/SliderTextValue.a11y.chromium.spec.ts: clear.
Co-authored-by: AKnassa <[email protected]>
|
/approve-spec 328cb1c |
There was a problem hiding this comment.
No blocking problems: the Slider's track now keeps one length while a text value changes, and the new FR8 and its compatibility lines are approved for this head.
Approval waits on two things outside the diff: the July changes-requested review needs its reviewer to re-review or dismiss it, and CI needs a re-run, because this head's run was refused for capacity before any check ran. Optional: FR8's Basis cell could use the present tense, the changeset could mention the shorter resting track and the end-aligned value the record now describes, and two comments in Slider.tsx (line 612 and lines 1693–1696) could be shortened.
Claims and files checked
- The track keeps its size while dragging with the text display: verified for labels within the reservation (Chromium: one 656 px track at 0, 50 and 100 in a 720 px viewport; on main it moves 16 px).
- A label that changes width squeezes the track and makes the thumb jitter: verified on main (672, 664 and 656 px at 0, 50 and 100).
- The label reserves a minimum width in
chfor the longest of the end, neighbour and quarter-point labels asformatValuewrites them, and aligns its text to the end: verified inSlider.tsx(lines 507, 609–642, 1697–1717). - The numerals keep today's typography: verified (no numeric font variant on main or this head).
- No hidden copy is rendered: verified (one text element, as on main).
- A format whose digits or other glyphs are wider than
0can still widen the label: verified from the mechanism (chis the width of0). - FR8 states the reservation and its limit, and its verification row names the new tests: verified.
- The decimal-precision fix is already on main and its tests were dropped here: verified (the rounding helpers are unchanged from main).
- The hidden sizer is replaced by a CSS reservation on the visible label: verified.
- A formatter whose longest label falls between the samples is not covered: verified (seven samples).
- The owner's July review asked to keep the numerals and suggested a hidden sizer, and the minimal-DOM rule adopted since forbids a hidden twin: verified.
- Stills comparing main and this head: not yet present; the description marks them pending.
- The changeset says what changes for builders: verified, including the wide-glyph limit; it leaves out the resting effects (optional note).
- The Storybook steps show a still track: verified in Chromium with keyboard steps.
- The unit suite passes with 110 tests and the five width tests fail on main: verified.
- The Chromium check measures one track length at the narrowest and the widest value and runs in pull request CI: verified that it passes against this head's Storybook build and that CI selects it by its component folder; CI did not run at this head.
- The knowledge check passes: verified.
- Writing rubric R1 to R7: verified for the FR8 sentence; the Basis cell narrates the old behaviour (optional note).
- It fixes the reported drag issue: verified.
- Changeset: the track no longer resizes while dragging, with the wide-glyph limit, as a Core patch: verified.
- Changeset: the value keeps the width of its longest likely label as
formatValuewrites it, so the thumb stays under the pointer: verified as a character reservation. .changeset/slider-track-width-stability.md: optional note (resting effects).docs/specs/components/Slider/Slider.spec.md: clear; Basis tense (optional).packages/core/src/Slider/Slider.tsx: clear; two optional comment edits.packages/core/src/Slider/Slider.test.tsx: clear.packages/core/src/Slider/__tests__/SliderTextValue.a11y.chromium.spec.ts: clear.
| | FR5 | `onChangeEnd` fires once when an interaction ends — a pointer drag or track press is released or cancelled (after a release, once its coast settles; FR7), or a keyboard step (arrow, Page, Home, End) completes — and carries the value the owner renders after its synchronous response to that interaction's `onChange` calls, including any clamp, snap, or rejection; it never carries a value Slider emitted that the owner did not render. A range reports both values the same way. | Maintainer decision (DEC-3) | Approved | | ||
| | FR6 | When both thumbs of a range share a value, a pointer press takes the thumb that can travel toward the pointer: a press on the track beside them takes the thumb on its side, and a press on the thumbs or on their shared value, such as its mark label, moves neither until the pointer moves, when the direction of that first movement picks the thumb, which takes the drag's focus, pressed state and value tooltip. Until then the upper thumb, drawn over the lower one, holds the press, its focus and its pressed state, so a press that never moves changes no value and leaves focus on the upper thumb. A drag that began on the shared thumbs and comes back past their value moves the other thumb: the dragged thumb stops against it and the other follows the pointer, so with both at 80 a drag to 95 and back to 50 ends at [50, 80]. | Current source and focused tests | Accepted contract | | ||
| | FR7 | Every pointer — a finger, a pen, or a mouse — drags a thumb by its travel. A press on a thumb changes no value. Once the pointer has moved `spec:AST-094/FR19`'s 10 px from where it pressed — a distance the pointer travels, not a zone around the thumb — the value moves by the pointer's further travel along the track over the track's length, from wherever the thumb was grabbed, so the thumb never jumps to the pointer; each move is written to the thumb with no component render (`spec:AST-094/FR9`). Between coincident range thumbs, FR6's first movement is the one that crosses the 10 px. A finger or a pen claims the drag only along the track, so a swipe across it scrolls the page; a mouse claims in any direction. Under a coarse primary pointer, after hydration (`spec:AST-094/FR13`), each thumb takes a finger or a pen through a 48 px touch target that grows toward a range's other thumb only to half the gap (`spec:AST-094/FR42`), and the held thumb lifts and drops back on springs, `springs.sliderLift` and `springs.sliderDrop`, since Slider's main interaction is a gesture (`spec:AST-094/FR45`). A finger's or a pen's drag that brings the value to either end plays UISlider's end haptic where the browser can vibrate, and a mouse's drag plays none; iOS Safari has no haptic for that moment (`spec:AST-094/FR23`). After any pointer's release, a finger's, a pen's or a mouse's, the thumb coasts toward 0.4 of the release's momentum projection and settles on the `springs.sliderRelease` motion role, about 0.6 s, with `onChange` firing through the coast (`spec:AST-094/FR45`); the role is internal, with UISlider's measured value at `tempo` 1 and `'standard'`, and follows the theme's motion knobs (`spec:AST-094/FR4`). Implementation gap: a mouse's or a pen's drag ends at its release, with no coast. A tap or a click on the track still sets the value: a finger's tap when it lifts, and a mouse press at once, where a primary click lands; a secondary click and a wheel or trackpad scroll change nothing (`spec:AST-094/FR43`). Under reduced motion the thumb does not lift, a tap's value applies at once, and the coast continues (`design:reduced-motion/DR2`). | UIKit measurements and maintainer decision (DEC-4) | Approved | | ||
| | FR8 | The text value display keeps one inline size while the value changes: it reserves the width of its longest likely label (the ends, their neighbours and the quarter points) in characters, so the track keeps its length during a drag. A custom format whose digits or other glyphs are wider than `0` can still widen the label slightly past the reservation. | Defect repair: the text value's width followed the value, so the track's length changed during a drag and the thumb moved under the pointer. | Defect repair; no new behavior decided | |
There was a problem hiding this comment.
Non-blocking: the Basis cell narrates main's behaviour in the past tense ("the text value's width followed the value, so the track's length changed…"), which the writing rubric's R1 asks to avoid. Suggested: "Defect repair: a text value whose width follows the value changes the track's length during a drag."
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] Slider: the track no longer resizes while dragging with `valueDisplay="text"`. The value text keeps the width of its longest likely label (the ends, their neighbours and the quarter points, as your `formatValue` writes them), so the thumb stays under the pointer instead of shifting as the label grows and shrinks. A format with digits or other glyphs wider than `0`, such as `%`, can still widen it slightly. (#4050) |
There was a problem hiding this comment.
Non-blocking: the record's new compatibility line says the resting track is shorter and a short value sits at the end of its box, away from the track; this release note says only that the track stops resizing. Suggested addition: "At rest the track is shorter by the reserved room, and a short value sits at the end of it."
Co-authored-by: AKnassa <[email protected]>
|
/approve-spec 7acddeb |
There was a problem hiding this comment.
Approval is on hold: no blocking problem remains, and component:Slider FR8 is approved by an engineering owner at this head, but cixzhang's changes-requested review from July is still open, and only her re-review or dismissal clears it. CI also needs a re-run, since this head's run was turned away because CI was full.
The text value now keeps the track one length while it changes (a 16 px drift on main becomes 0.01 px in Chromium), the width tests fail on main and pass here, and the new Chromium check passes against this head's Storybook.
Non-blocking suggestions, already in the inline threads:
- FR8's Basis cell could use the present tense ("a text value whose width follows the value changes the track's length during a drag").
- The release note could add that the resting track is shorter by the reserved room and a short value sits at its end.
- Two new comments in
Slider.tsx(lines 612 and 1693-1696) restate the code or run long.
Claims and files checked
- Claim: the track no longer resizes while dragging with the text display — verified (width tests fail on
main, pass here; Chromium track spread 16.01 px onmain, 0.01 px here). - Claim: the label reserves the width of its longest likely label from the ends, their neighbours and the quarter points, as
formatValuewrites them — verified (Slider.tsx:621-642,:1698-1711). - Claim: a format with glyphs wider than
0, such as%, can still widen it slightly — verified (a100%label overflows its 4-character box by 3.64 px). - Claim: the label end-aligns in its box — verified (
Slider.tsx:507). - Claim: the numerals keep today's typography — verified (computed
font-variant-numeric: normalonmainand here). - Claim: no hidden copy is rendered — verified (the row has the same element count on
mainand here). - Claim: FR8 states the reservation and its limit, and its verification row names the new tests — verified (
Slider.spec.md:127,:279). - Claim: the decimal-precision fix is already on
main, so its tests were dropped here — verified (snapToSteprounds to the precision ofminandsteponmain; the diff adds no precision tests). - Claim: a custom
formatValuewhose longest label falls between the samples is not covered — verified (seven samples per render). - Claim: the stills show a track that drifts on
mainand holds on this head — consistent (this review measured 16.01 px and 0.01 px at a 720 px viewport). - Claim: the Slider code is unchanged since the commit the stills were taken from — verified (no diff in
Slider.tsx). - Claim:
Slider.test.tsxpasses 110 tests, and the five width tests fail onmain— verified. - Claim: the Chromium spec measures one track length and pull request CI runs it — verified (passes here; it is selected as a changed spec), though CI did not run at this head.
- Claim: the knowledge check passes — verified.
- Claim: the changeset says what changes for builders — verified, apart from the resting effects noted above.
- File
.changeset/slider-track-width-stability.md— non-blocking note. - File
docs/specs/components/Slider/Slider.spec.md— non-blocking note. - File
packages/core/src/Slider/Slider.tsx— non-blocking note. - File
packages/core/src/Slider/Slider.test.tsx— clear. - File
packages/core/src/Slider/__tests__/SliderTextValue.a11y.chromium.spec.ts— clear.
(Posted by Cindy's agent.) Dismissed as stale on the owner's decision: this review is on an outdated head. Please re-review the current head if concerns remain.
#4050 reserved the text value's width in characters, end-aligned, with no hidden copy, for the ends and their neighbours; this pull request arrived at the same shape. Co-authored-by: AKnassa <[email protected]>
What this does
Fixes the Slider so the bar stays the same size while you drag the knob with
valueDisplay="text".Screen.Recording.2026-07-18.at.12.27.39.AM.mov
Why
The value label next to the slider changed width as the number changed (for example "9" becoming "10"). That squeezed the bar, which moved the knob under the pointer, which changed the number again, so the slider jittered while dragging (
component:SliderFR7: the value moves by the pointer's travel along the track over the track's length).What changed
ch) for the longest of the labels at the ends, their neighbours and the quarter points, asformatValuewrites them, and aligns its text to the end of that box. Its numerals keep the typography they have today. No hidden copy is rendered (architecture:component-style-authoringINV7).0can still widen the label slightly past the reservation.component:SliderFR8 (defect repair) states the reservation and its limit, and its verification row names the new tests.Maintainer carry
Reshaped by a maintainer on top of @AKnassa's branch (thank you!), keeping its commits and crediting them:
main. The decimal-precision half of this pull request is already onmain(Slider rounds snapped values to the precision ofminandstep), so its precision tests were dropped here.formatValuewhose longest label falls between the sampled points is not covered.chand leaves the numerals' typography as it is today; the stills show main and this head.Stills (real Chrome, light theme; main vs this head)
Taken from
core-slider--custom-step(0 to 100 by 10, text value) at main and at c0a2309 (the Slider code is identical at this head). The label's computedfont-variant-numericisnormalin every shot on both builds, so the numerals look as they do today.Track width (px) by value, set with the keyboard:
How to see it
Open the Slider story in Storybook (
pnpm -F storybook dev, then Core → Slider), setvalueDisplaytotext, and drag the knob back and forth without releasing: the track stays still.Testing
Slider.test.tsx: 110 passed, including "text value display width stability" (5), which fail onmain, where the text value reserves no width.SliderTextValue.a11y.chromium.spec.tsmeasures one track length at the narrowest and the widest value in Chromium (pull request CI runs it).pnpm check:knowledgepasses.Writing rubric results
Fixes #4033
Owner and land path
Owner: the Astryx fix loop, lane 3. Carried by lane 3 for the contributor. After #11547 lands: merge main, Specs re-stamp, CodeBunny, green CI including WebKit, owner approval; the drain merges.