zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
890 stars 232 forks source link

Incorrect thumb value provided to component and also value breaks on thumb moving #247

Closed gabrielmicko closed 2 years ago

gabrielmicko commented 2 years ago

Description

<ReactSlider
    min={0.11}
    max={77.77}
    value={v}
    onChange={v => setV(v)}
 />

When I move the thumb left the max value breaks.

https://user-images.githubusercontent.com/4391461/150234656-3959660d-be1a-403c-8799-35bec28e2edc.mov

CodeSandbox

Please provide a CodeSandbox that clearly reproduces the issue. Issues without a CodeSandbox are less likely to get resolved quickly.

Edit zillow/react-slider

gabrielmicko commented 2 years ago

I am not sure yet, but I think when I provide prop step={0.01} it works.

kris-ellery commented 2 years ago

@gabrielmicko please use step={0.01} and update onChange handler to use spread operator for setting a value.

<ReactSlider
  step={0.01}
  onChange={(v) => setV([...v])}
  // ...
/>

I applied these changes to your CodeSandbox example and everything worked/updated as expected.