Repository navigation
fix(slider): round snapped values to the min/step decimal precision - #3897
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 |
cixzhang
approved these changes
Jul 30, 2026
cixzhang
left a comment
Contributor
There was a problem hiding this comment.
Nice thanks for fixing these fractionals
cixzhang
enabled auto-merge (squash)
July 30, 2026 04:29
AKnassa
added a commit
to AKnassa/astryx
that referenced
this pull request
Sep 26, 2026
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.
AKnassa
added a commit
to AKnassa/astryx
that referenced
this pull request
Sep 26, 2026
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.
This branch was successfully deployed
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.
With fractional steps,
snapToStepcomputedmin + steps * step, which accumulates binary floating-point error: a keyboard nudge on astep={0.1}slider emitted0.30000000000000004throughonChange/onChangeEnd, and the value leaked intoaria-valuenowand the value tooltip once the consumer echoed it back. Snapped values are now rounded to the combined decimal precision ofminandstep(handling exponent-notation steps like1e-7, capped at 20 digits fortoFixed). A legitimately snapped value can never carry more decimals than min and step combined, so the rounding removes only the error — exact steps are unchanged.Test plan:
New tests drive fractional-step sliders via keyboard in both single and range mode and assert
onChangereceives exact decimals (0.3, not 0.30000000000000004).