Bug report
Current Behavior
When step is <= 1e-7, the slider is non-responsive to dragging the thumbs.
Expected behavior
Slider should work as normal, even for small step values.
Suggested solution
The problem is in getDecimalCount:
|
function getDecimalCount(value: number) { |
|
return (String(value).split('.')[1] || '').length; |
|
} |
This implementation only works for numbers whose JS string representation is decimal. For very small numbers (<= 1e-7), JS changes the string representation to scientific notation (i.e. no decimal places, except maybe in the coefficient).
Your environment
| Software |
Name(s) |
Version |
| Radix Package(s) |
react-slider |
1.1.1 |
| React |
n/a |
18 |
| Browser |
|
18.2 |
| Assistive tech |
|
|
| Node |
n/a |
22 |
| npm/yarn/pnpm |
|
11.6.2 |
| Operating System |
|
macOS |
Bug report
Current Behavior
When step is <= 1e-7, the slider is non-responsive to dragging the thumbs.
Expected behavior
Slider should work as normal, even for small step values.
Suggested solution
The problem is in
getDecimalCount:primitives/packages/react/slider/src/slider.tsx
Lines 783 to 785 in 22473d1
This implementation only works for numbers whose JS string representation is decimal. For very small numbers (<= 1e-7), JS changes the string representation to scientific notation (i.e. no decimal places, except maybe in the coefficient).
Your environment