Skip to content

Slider: stop the track from resizing while you drag - #4050

Closed
AKnassa wants to merge 14 commits into
meta:mainfrom
AKnassa:ak-4033-slider-track-stability
Closed

AKnassa wants to merge 14 commits into
meta:mainfrom
AKnassa:ak-4033-slider-track-stability

Conversation

@AKnassa

@AKnassa AKnassa commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

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:Slider FR7: the value moves by the pointer's travel along the track over the track's length).

What changed

  • The value label keeps the width of its longest likely label, so the bar keeps its length mid-drag. The label takes a minimum width in characters (ch) for the longest of the labels at the ends, their neighbours and the quarter points, as formatValue writes 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-authoring INV7).
  • Limit: a custom format whose digits or other glyphs are wider than 0 can still widen the label slightly past the reservation.
  • A new component:Slider FR8 (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:

  • Merged main. The decimal-precision half of this pull request is already on main (Slider rounds snapped values to the precision of min and step), so its precision tests were dropped here.
  • The hidden sizer (up to about 200 labels per value) is replaced by a CSS reservation on the visible label, since INV7 allows no hidden twin to reserve space. A custom formatValue whose longest label falls between the sampled points is not covered.
  • The owner's 07-26 review asked to avoid changing the Slider's numerals and suggested the hidden-text sizer used elsewhere. The style-authoring rule adopted since (INV7, 10-24) forbids a hidden twin, so this head reserves the width on the visible label in ch and leaves the numerals' typography as it is today; the stills show main and this head.
  • The changeset says what changes for builders.

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 computed font-variant-numeric is normal in every shot on both builds, so the numerals look as they do today.

Track width (px) by value, set with the keyboard:

Build Viewport 0 10 50 90 100 Spread
main 390 342.20 334.42 334.42 334.42 326.64 15.56
this head 390 326.66 326.66 326.66 326.66 326.64 0.016
main 1280 1232.20 1224.42 1224.42 1224.42 1216.64 15.56
this head 1280 1216.66 1216.66 1216.66 1216.66 1216.64 0.016
Viewport Shot main this head
390 Home (0) main 390 home head 390 home
390 End (100) main 390 end head 390 end
390 mid-drag (about 60%) main 390 mid-drag head 390 mid-drag
1280 Home (0) main 1280 home head 1280 home
1280 End (100) main 1280 end head 1280 end
1280 mid-drag (about 60%) main 1280 mid-drag head 1280 mid-drag

How to see it

Open the Slider story in Storybook (pnpm -F storybook dev, then Core → Slider), set valueDisplay to text, 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 on main, where the text value reserves no width.
  • SliderTextValue.a11y.chromium.spec.ts measures one track length at the narrowest and the widest value in Chromium (pull request CI runs it).
  • pnpm check:knowledge passes.

Writing rubric results

  • R1 present tense: pass; the FR8 sentence states what the text value does.
  • R2 research: none in the record.
  • R3 evidence: the FR8 verification row names its tests; its basis states the observed defect, with no issue reference.
  • R4 rejected alternatives: none.
  • R5 change references: none in the record (FR8's basis names the defect, not the issue).
  • R6 open questions: none.
  • R7 project status: none.

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.

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
@vercel

vercel Bot commented Jul 18, 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 Nov 14, 2026 8:48am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 18, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 18, 2026
@AKnassa
AKnassa marked this pull request as ready for review July 18, 2026 04:28
@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 7acddeb

Storybook · Sandbox · built from this PR's head

Modified components

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

Comment thread packages/core/src/Slider/Slider.tsx Outdated
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;

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.

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?

@cixzhang

Copy link
Copy Markdown
Contributor

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?

@astracat-bot astracat-bot Bot 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 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 emits 2e-7 instead of 2.46e-7 (also in aria-valuenow). Please account for the mantissa's decimal digits and add a test for that step.
  • The track can still resize with custom formatValue: reserving ch units from the character counts of only min, max, min + step, and max - step misses 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 keeping tabular-nums versus 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.
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Sep 26, 2026
@AKnassa

AKnassa commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the slow reply, @cixzhang. I'd like to keep carrying this. I've pushed up to e8731d4:

  • Merged main. The conflicts were in the decimal-step snapping, which fix(slider): round snapped values to the min/step decimal precision #3897 already shipped. I took main's getDecimalPrecision/snapToStep unchanged, dropped my copy, and removed the decimal-step line from the changeset. I also added a test that stepping by 1.23e-7 twice gives 2.46e-7 in both onChange and aria-valuenow (e31ac4c).
  • Your ch question: I agree, and I've dropped ch and tabular-nums, so the typography doesn't change. ch only matches the width of the 0 glyph, so it reserved too little for % labels and for a formatValue whose widest label falls mid-range. Each value now sits in an inline-grid slot on top of an aria-hidden, visibility: hidden sizer that lists every reachable formatted label. It's the same idea as Tab's labelSizer and ToggleButton's width reservation. Ranges over 200 steps are sampled, and range mode sizes each side separately. New tests cover a mid-range-widest word formatter, % labels, range mode, decimal steps and long ranges (e31ac4c).
  • e8731d4 restores 32 unrelated files that the pre-commit hook reformatted during the merge. The diff against main is now just the Slider source, its tests and the changeset.

Still to do on my side: update the PR description, which still mentions the decimal-step fix and equal-width numerals.

@astracat-bot astracat-bot Bot 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 for carrying this through the rebase and rework — this revision addresses both issues from the previous review:

  • Track sizing no longer estimates width. The ch reservation and tabular-nums are 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-7 twice emits and announces 2.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

@astracat-bot astracat-bot Bot 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 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 main already 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]

Comment thread packages/core/src/Slider/Slider.tsx Resolved
@cixzhang
cixzhang marked this pull request as draft November 13, 2026 02:33
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 02:34
@cixzhang

Copy link
Copy Markdown
Contributor

/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]>
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 13, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec c0a2309

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 13, 2026

@kentonquatman kentonquatman 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 @AKnassa! Design looks good 👍

@astracat-bot astracat-bot Bot 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.

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 ch for the longest of the end, neighbour and quarter-point labels and aligns its text to the end: verified in Slider.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 0 can still widen the label: verified from the mechanism (ch is the width of 0).
  • 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 formatValue writes 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.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 328cb1c

@astracat-bot astracat-bot Bot 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.

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 ch for the longest of the end, neighbour and quarter-point labels as formatValue writes them, and aligns its text to the end: verified in Slider.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 0 can still widen the label: verified from the mechanism (ch is the width of 0).
  • 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 formatValue writes 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.

Automated review (maintainer link)

| 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 |

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.

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)

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.

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."

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 7acddeb

@astracat-bot astracat-bot Bot 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.

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 on main, 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 formatValue writes them — verified (Slider.tsx:621-642, :1698-1711).
  • Claim: a format with glyphs wider than 0, such as %, can still widen it slightly — verified (a 100% 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: normal on main and here).
  • Claim: no hidden copy is rendered — verified (the row has the same element count on main and 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 (snapToStep rounds to the precision of min and step on main; the diff adds no precision tests).
  • Claim: a custom formatValue whose longest label falls between the samples is not covered — verified (seven samples per render).
  • Claim: the stills show a track that drifts on main and 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.tsx passes 110 tests, and the five width tests fail on main — 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.

Automated review (maintainer link)

@cixzhang
cixzhang dismissed their stale review November 18, 2026 21:22

(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.

cixzhang added a commit that referenced this pull request Nov 18, 2026
#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]>
@cixzhang cixzhang closed this in b6ba5ee Nov 22, 2026
@github-actions
github-actions Bot deleted the ak-4033-slider-track-stability branch November 22, 2026 14:02

This branch was successfully deployed

1 active deployment
Preview — 7acddebd Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Slider component - track size changes often

3 participants