Slider: stop the track from resizing while you drag#4050
Open
AKnassa wants to merge 1 commit into
Open
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 facebook#4033
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
AKnassa
marked this pull request as ready for review
July 18, 2026 04:28
AKnassa
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 18, 2026 04:28
Contributor
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Fixes the Slider so the bar stays the same size while you drag the knob, and makes the numbers it shows clean (no more
0.30000000000000004).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 (like "9" becoming "10"), which squeezed the bar, which moved the knob under your mouse, which changed the number again — so the whole thing jittered while dragging. And with decimal steps, the label could show long floating-point garbage.
What changed
aria-valuenow), and in the value given to your code (onChange).How to see it
Open the Slider story in Storybook (
pnpm -F storybook dev, then Core → Slider) and drag the knob back and forth without releasing — the track stays perfectly still and the numbers stay tidy. Six new tests cover the width reservation and the decimal-step precision.Fixes #4033