Skip to content
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

Slider label shows floating point rounding errors #725

Closed
as-com opened this issue Feb 24, 2017 · 2 comments
Closed

Slider label shows floating point rounding errors #725

as-com opened this issue Feb 24, 2017 · 2 comments

Comments

@as-com
Copy link

as-com commented Feb 24, 2017

Bug report

  • Package version(s): 1.9.0
  • Browser and OS versions: Firefox Developer Edition 53.0a2 (also happened in other browsers)

Steps to reproduce

<Slider 
  onChange={(value) => { this.setState({ value }) }} 
  value={this.state.value}
  stepSize={0.1}
/>

(http://www.webpackbin.com/Ek8qyKYFG)

  1. Drag slider around

Actual behavior

slider-fp

Expected behavior

Slider label displays expected step values.

Perhaps this could be fixed by rounding to the number of significant digits given in stepSize.

@giladgray
Copy link
Contributor

this is easily handled by a custom renderLabel, but is not supported out-of-the-box currently.

<Slider renderLabel={(value) => value.toFixed(2)}` />

@giladgray
Copy link
Contributor

when using fractional (<1) steps, you pretty much have to do the above code.

we'd also happily accept a PR to add a precision prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants