react-component / react-component/slider
getPrecision always returns 0 when step size value is an integer
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 768
- Avg merge
- 11d 22h
- Merged PRs (30d)
- 5
Description
When the value for the step size is an integer, the function getPrecision (https://github.com/react-component/slider/blob/9.2.4/src/utils.js#L35) always returns a precision of 0, which is not desired. There should be a way to pass the precision of a step to allow a situation as the following:
const sliderProps = {
value: 5.5,
step: 3,
min: 2.5,
max: 20.5
};
In the situation above, the handle won't take a value lower than 3 with the current implementation in v9.2.4. Although the closest point of 2.5 is found when dragging the handle, the ensureValuePrecision function (https://github.com/react-component/slider/blob/9.2.4/src/utils.js#L69) will round it off to an integer (3 in this case).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/utils.js at getPrecision and ensureValuePrecision, then trace how the step size and minimum value reach those helpers. Verify the reported case with value 5.5, step 3, min 2.5, and max 20.5; done means the slider can retain the valid minimum of 2.5 instead of rounding it to 3.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100