Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Thanks for the careful endpoint fix and regression coverage. The implementation reads as matching the policy you describe — pointer and End can reach the explicit maximum, and arrow keys visit the adjacent selectable value instead of skipping it — and this review found no concrete code defect in the single or range cases.
Approval is waiting on a maintainer decision, though. Slider's current governing contract covers its anatomy and theming and does not settle whether the explicit maximum should join the selectable set when the step does not divide the range, including the shorter final interval, preferring maximum on a tie, arrow movement from off-grid values, and the range-thumb separation case. A maintainer needs to provide or identify the governing spec for that addition before it can be approved; please do not treat this as a request to rewrite the fix or to author the spec yourself.
Once that policy is settled in favour, the remaining step is normal verification on the merged result. If it is settled the other way, the endpoint behaviour would need to change accordingly.
[Automated review]
There was a problem hiding this comment.
Thanks for the careful endpoint fix and regression coverage. The implementation matches the policy you describe — pointer and End can reach the explicit maximum, and arrow keys visit the adjacent selectable value instead of skipping it — and this review found no concrete code defect in the single or range cases; the focused tests and browser checks for the step=3 case pass.
Approval is waiting on a maintainer decision, though. Slider's current governing contract covers its anatomy and theming and does not settle whether the explicit maximum should join the selectable set when the step does not divide the range, including the shorter final interval, preferring maximum on a tie, arrow movement from off-grid values, and the range-thumb separation case. A maintainer needs to provide or identify the governing spec for that addition before it can be approved; please do not treat this as a request to rewrite the fix or to author the spec yourself.
Once that policy is settled in favour, the remaining step is normal verification on the merged result. If it is settled the other way, the endpoint behaviour would need to change accordingly.
[Automated review]
PR Analysis Report
The exact-head preview is not available yet. Generated by PR Enrichment workflow | View current CI run |
8c71d93 to
304289e
Compare
There was a problem hiding this comment.
Thanks for the careful fix and tests: the implementation does what the description says and this review found no code defect, but approval is waiting on a maintainer decision rather than on changes from you. Slider's current spec does not say whether the explicit max is a selectable value when step does not divide the range, so a maintainer needs to provide or identify the governing spec for that addition, covering End and dragging reaching max, the shorter final interval with max preferred on a tie, arrow keys moving to the adjacent selectable value from any off-grid value, and the same rule for range thumbs under minStepsBetweenThumbs. For that decision, note that on main ArrowRight from 99 already reaches 100 while End and dragging stop at 99 (step={3}), so today's behaviour is not consistently grid-only either. If the policy is accepted, two small optional touch-ups would help (mention in the changeset that arrow keys now stop at the adjacent value from any off-grid value, not only next to the maximum, and keep the file header's existing note that unfilled marks share the track token), and there is no need for you to write the spec.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] Keep Slider endpoints selectable when the step does not divide the range. Pointer input and End now reach the explicit maximum, and arrow keys move between that endpoint and its nearest step without skipping a value. |
There was a problem hiding this comment.
Non-blocking: the code also changes arrow-key movement from any off-grid value, not only next to the endpoint. For example, with step={10} and value={55}, ArrowRight now goes to 60 instead of 70. If maintainers accept this policy, consider saying so here so the release note covers it.
There was a problem hiding this comment.
Addressed in 4ba130d206. The changeset now explicitly covers arrow-key movement from any off-grid value, including the step={10}, value={55} example: ArrowRight selects 60 instead of 70.
This is a documentation-only follow-up; the endpoint/off-grid policy still awaits the maintainer decision noted in the review.
| * @file Slider.tsx | ||
| * @input Uses React, useId, useRef, useCallback, Field, Tooltip, useTooltip, VisuallyHidden | ||
| * @output Exports Slider and its props; unfilled marks share the track token; modifier-only key presses do not restore the thumb focus ring | ||
| * @output Exports Slider and its props; explicit endpoints remain selectable with off-grid steps, and arrow keys visit adjacent steps |
There was a problem hiding this comment.
Non-blocking: this drops "unfilled marks share the track token" from @output. That is still true (the mark style paints --color-track), so it could stay beside the new note.
There was a problem hiding this comment.
Fixed in 4ba130d206. Restored "Unfilled marks share the track token" in the file header alongside the endpoint and focus-ring notes. No runtime behavior changed.
There was a problem hiding this comment.
Thanks for the fix and the regression tests. This needs changes from you, and approval also waits on a maintainer decision. Since this branch was cut, main has shipped End reaching an off-grid max and settled the arrow and Page keys in the Slider spec (the key result snaps to the nearest step, then clamps), so please rebase onto main, keep its key handling, and drop the snap-first arrow and Page logic, which also fixes the arrow keys getting stuck at 7 or 57 for a controlled value={fraction * 100}. Whether a drag, track press or mark press should select an off-grid max (the nearest of the step grid plus max, ties going to max) is not settled by the current Slider spec, so a maintainer needs to provide or identify the governing spec for that pointer rule before it can be approved; you don't need to write it.
[Automated review]
| const snapped = snapToStep(currentVal, min, step); | ||
| let newVal: number; | ||
|
|
||
| switch (e.key) { | ||
| case 'ArrowRight': | ||
| case 'ArrowUp': | ||
| newVal = currentVal + step; | ||
| newVal = | ||
| snapped > currentVal | ||
| ? snapped | ||
| : snapToStep(currentVal + step, min, step); | ||
| break; | ||
| case 'ArrowLeft': | ||
| case 'ArrowDown': | ||
| newVal = currentVal - step; | ||
| newVal = | ||
| snapped < currentVal | ||
| ? snapped | ||
| : snapToStep(currentVal - step, min, step); |
There was a problem hiding this comment.
Arrow keys can stall on floating-point noise. snapped > currentVal and snapped < currentVal are exact comparisons, so a controlled value that is off the grid only by binary rounding counts as off-grid, and the press just returns its grid value. When the caller maps that value back the same way, the next render brings the noise back and the thumb never moves: with value={fraction * 100} and onChange={v => setFraction(v / 100)} (default step), stepping down from 10 stops at 7 (0.07 * 100 is 7.000000000000001), and stepping up from 55 stops at 57. main keeps stepping. Treating a value within rounding tolerance of snapped as on the grid avoids it, for example:
const snapped = snapToStep(currentVal, min, step);
const offGrid = Math.abs(snapped - currentVal) > Math.abs(step) * 1e-9;
// ArrowRight / ArrowUp; mirror it for ArrowLeft / ArrowDown
newVal =
offGrid && snapped > currentVal
? snapped
: snapToStep(currentVal + step, min, step);A regression test with a fraction-backed controlled value would keep it fixed.
|
Closing as superseded by #7516. Posted by Cindy's agent on her behalf. |
User impact
With
min={0},max={100}andstep={3}, Slider stops at99when dragged to the right endpoint or operated with End. Its accessible maximum is still100, but neither input method can select it.Fixes #6735
Problem and solution fit
The value is rounded to the step grid before it is clamped. At the endpoint,
100rounds to99; clamping leaves it there because it is already within bounds. A second edge case appears when the current value is an off-grid maximum: subtracting a step and then rounding takes100 → 97 → 96, skipping the adjacent value99.The fix includes the explicit maximum in nearest-value selection and makes arrow keys choose the adjacent step in their direction. The final interval may be shorter than
step:96 → 99 → 100, and back through99rather than skipping it.Expected behavior and authority
maxas its maximum value. The existing implementation already permits an off-grid maximum when rounding overshoots and clamping brings it back:min=0, max=100, step=6reaches100today. This restores consistent endpoint reachability rather than making it depend on the remainder.maxas allowed; it does not claim that WCAG requires this particular step policy or that it matches native HTML range sanitization.Smallest restoration
Slider.tsx: share nearest-step/endpoint selection across pointer and keyboard updates, and select the adjacent step before applying bounds on arrow-key movement. Existing decimal cleanup, range separation, and callback handling stay in place. No new props, styling, dependencies, or default values.Three regression tests cover single-value keyboard/callback behavior, range separation and ARIA bounds, and pointer dragging to both
100and the neighboring99.Evidence
Reproduce
step=3.aria-valuemax="100".AS-IS / TO-BE: real Chrome 153 keyboard and mouse input, published Storybook versus this branch at
b46a9c0ec8. The diagnostic panels are injected by the probe; their values are read from the live DOM after each action. They are not product UI.Before recording · After recording · Probe, raw observations, and test logs
Representative unchanged keyboard paths, checked on both builds:
min=0, max=100, step=10100 → 90min=0, max=100, step=6100 → 96min=1, max=100, step=3100 → 97min=-1, max=100, step=3100 → 98The published deployment is not asserted to be the exact base commit. For regression proof, the same new tests were run with a temporary Vite hook substituting only Slider's source:
f138ed997b99instead of100currentValue ± steparrow logic96instead of99The probe configs and logs are linked above. No live source was swapped, and the tested source hashes match the committed files. These are scoped Chromium checks, not a full assistive-technology or cross-browser audit.
Scope
Testing
pnpm exec vitest run packages/core/src/Slider/Slider.test.tsx— 68 passed.pnpm test --maxWorkers=4— 17,113 passed, 50 skipped (GNUcpon PATH; see note below).pnpm -F @astryxdesign/core typecheck— passed.pnpm -F @astryxdesign/core typecheck:docs— passed.pnpm build— passed.pnpm lint:strict— 0 errors; 84 warnings outside Slider.The first full run on macOS passed 17,105 tests but hit two unrelated setup-fixture failures because BSD
cpdoes not support--reflink=auto. The entire suite was rerun with GNUcp9.11 on PATH usingpnpm test --maxWorkers=4; no test exclusions or repository fixes were added for that environment issue.