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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Slider] Display valueLabel when dragging slider with onChangeCommitted prop. #27800

Closed
1 task done
imsuvesh opened this issue Aug 16, 2021 · 2 comments
Closed
1 task done
Labels
component: slider This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@imsuvesh
Copy link

imsuvesh commented Aug 16, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 馃挕

Slider valueLabel and thumb don鈥檛 change their position when dragging slider using onChangeCommitted prop.
When using onChange prop it is working fine but why not implement the same behavior for onChangeCommitted too?
Call the change function when onmouseup event triggers?

Examples 馃寛

https://codesandbox.io/s/material-demo-forked-vxsmr?file=/demo.js:1235-1252

Motivation 馃敠

I would like to display valuelabel of the slider when a user is dragging over the slider. It would show current value to the user and he would be able to select his desired value on one go, instead of clicking and dragging on slider multiple time to get his desired result.
Currently, it is very difficult to select a specific value in Slider by using onChangeCommitted prop because we are not able to see the current value when dragging.

@imsuvesh imsuvesh added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 16, 2021
@eps1lon
Copy link
Member

eps1lon commented Aug 17, 2021

Thanks for the feedback.

When dragging the value is not committed. Therefore onChangeCommitted isn't called. This is explained in https://material-ui.com/api/slider/#props:

onChangeCommitted Callback function that is fired when the mouseup is triggered.

On the other hand, Input does not implement onChagenCommitted which is why you get a warning in the console: Warning: Unknown event handler property `onChangeCommitted`. It will be ignored.

When using onChange prop it is working fine but why not implement the same behavior for onChangeCommitted too?

Why would we need two different props if they implement the same behavior?

@eps1lon eps1lon closed this as completed Aug 17, 2021
@eps1lon eps1lon added status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 17, 2021
@imsuvesh
Copy link
Author

@eps1lon Thank You for replying

When dragging the value is not committed. Therefore onChangeCommitted isn't called. This is explained in https://material-ui.com/api/slider/#props:

onChangeCommitted Callback function that is fired when the mouseup is triggered.

Ok, that's Nice, I missed it thanks for the correction.

On the other hand, Input does not implement onChagenCommitted which is why you get a warning in the console: Warning: Unknown event handler property `onChangeCommitted`. It will be ignored.

A gentle Sorry on the input part csb didn't saved it correctly that's why you saw the earlier version of code. Corrected it anyways...

When using onChange prop it is working fine but why not implement the same behavior for onChangeCommitted too?

Why would we need two different props if they implement the same behavior?

My suggestion is why not implement the same behavior for valueLabel and dragging thumb for onChangeCommitted, not to actually put the whole onChange prop functionality.
onChangeCommitted prop is currently working fine and doing what it is supposed to do but, the problem is you don't see the label or thumb movement when you drag which doesn't look good/stylish/rich experience as a user.

See the below gif -
pic1
https://codesandbox.io/s/material-demo-forked-vxsmr?file=/demo.js
Here when using onChange when I drag the slider, you can see the change in Label value and movement in the slider which helps me understand at what value I am currently dragging and when I have to stop.
But when I use onChangeCommitted prop, I can't see any slider movement and change in label value until I do mouseup.

The purpose of this whole long rant is, I want to use onChangeCommitted prop and also would like to show label and slider movement because my client wants the slider and I am using onChangeCommitted prop and he complains that he can't see any movement when he drags the slider, I can use onChange to make it look interactive but then it updates state on each step which I don't want.

@oliviertassinari oliviertassinari added the component: slider This is the name of the generic UI component, not the React module! label Aug 21, 2021
@oliviertassinari oliviertassinari changed the title Display Slider valueLabel when dragging slider with onChangeCommitted prop. [Slider] Display valueLabel when dragging slider with onChangeCommitted prop. Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

3 participants