react-component / slider

React Slider
https://slider.react-component.now.sh/
MIT License
3.04k stars 771 forks source link

onAfterChange #849

Open wozzo opened 1 year ago

wozzo commented 1 year ago

The change in https://github.com/react-component/slider/pull/812 added /** @deprecated It's always better to useonChangeinstead */ to onAfterChange.

I use both onChange and onAfterChange. We have questions which we finalise, but this should only happen when the user has released the slider on the value they are setting it to. Is there an alternative to onAfterChange that will allow me to keep this behaviour once it is removed?

maik-brockhaus commented 1 year ago

Same question here.

As there is AFAICS no access to any proper input events, there´s also no notification when the user actually let go of any of the thumbs in a slider/range.

The Deprecation mark therefore is not a valid alternative. I only see possible workarounds like setTimeout, but still they would most likely not work reliably.

Either provide the events for the input, or please consider bringing back the before/after events as they bring a real business-value in certain use cases.

imclint21 commented 1 year ago

Same issue, does its a problem to use onAfterChange?

KonradKlimczak commented 1 year ago

When it's triggered it does not call the newest reference of this callback but, the one was pass when change started happening. I hope we get proper onAfterChange one day

PaulAtST commented 1 year ago

I am running into the same issue updating from 9 to 10. My application needs to know when the user finishes moving the slider and can lock in the value.

aaroncrawford commented 1 year ago

We utilize onAfterChange to set our store state inside our app. We have very wide ranges with many options for users, so spamming store changes using onChange isn't great for performance. We could introduce debounce to compensate, but ...why? We use both onChange to adjust the low/high marks along with onAfterChange to set the final value. I'm sure there's plenty of others out there too.

Is there a valid reason onAfterChange is being deprecated?

alextrepa commented 1 year ago

We also need the onAfterChange for our project. We do not want to add a save button for our UX. Saving it with the onChange event does not work for our case, it triggers to often and some values are lost. Like some other said, we could probably add a debounce logic to compensate.

If there is a way to get the exact same result with onChange that we use to have with onAfterChange, then I am not seeing it.

Kris-Pelteshki commented 1 year ago

FYI, these types of changes in v10 are concerning. This and other issues are why we would not consider using this library going forward.

mikechabotcandy commented 1 year ago

If the range slide is attached an API call, onChange will spam the endpoint. Using onAfterChange ensures side effects will only occur when the user has completed the action. Yes, debounce can work, but why use that when onAfterChange serves the better purpose.

antoineol commented 1 year ago

Similar use case here: call an API + close a popover containing the slider (closing while the user is dragging hurts the UX). I described it here: https://github.com/react-component/slider/issues/938

lalitlal commented 1 year ago

Can someone address this please?

zombieJ commented 1 year ago

Make sense.