-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floating step - different results with click and keyboard #179
Comments
@viters thanks for the detailed issue report! I don't think I would add this kind of sanitization logic to the component itself because it is the result of using JavaScript floats and not really the fault of the slider logic. Perhaps we can leverage our |
@stonebk I think libraries do fight with JS sometimes to hide this fight from users. There may be better solution, but I would not require users to handle this difference themselves. In other words, I think Maybe there is a way to unify how |
One example of handling this situation is presented by This is proper solution I think, setting the target precision based on Sorry for open/close missclick. |
Yeah, the more I think about it, it makes sense that we resolve the issue since we are the ones doing the addition/subtraction. |
Description
When I set step to floating value, like
0.1
- using slider with mouse is okay and everything works as expected.When I use keyboard to change slider value, there are floating point issues:
The issue is probably because of floating point operations at lines:
https://github.com/zillow/react-slider/blob/master/src/components/ReactSlider/ReactSlider.jsx#L730
https://github.com/zillow/react-slider/blob/master/src/components/ReactSlider/ReactSlider.jsx#L736
I could suggest solution like this:
@stonebk
If you think this solution is acceptable, I will make PR.
CodeSandbox
https://stackblitz.com/edit/react-oeujyh
The text was updated successfully, but these errors were encountered: