zillow / react-slider

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

Clicking the track does not trigger onAfterChange #180

Closed brandonaaron closed 4 years ago

brandonaaron commented 4 years ago

Description

Clicking directly on the track will trigger an onChange event but does not trigger onBeforeChange nor onAfterChange.

CodeSandbox

This can be seen on the docs but also reproduced in the code sandbox.

Edit zillow/react-slider

viters commented 4 years ago

I also would love onAfterChange to be triggered after every change. onChange triggers too often for some controlled-scenarios in which only the end result matters, where onAfterChange would be perfect. Although, now onAfterChange is rather useless, because it does not guarantee to capture all user interactions.

viters commented 4 years ago

At the same time, onSliderClick returns only one value even if slider contains multiple handles. It is less useful than receiving new value, because it is hard to tell which handle did change.

There is a workaround though @brandonaaron , you can bind to onSliderClick and use ReactSlider.getValue.

@stonebk I think one of these scenarios would be worth considering:

brandonaaron commented 4 years ago

Thanks for the workaround idea. I ended up using that for now.

Passing the whole value as the second parameter of onSliderClick makes the most sense to me with the priority of reducing breaking changes. I agree it is tech debt but probably better to take that on, rather than deal with breaking stuff.