-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Normalize onChange event parameters #11990
Comments
@jonrhall Interesting issue, I haven't looked at the Slider implementation, so I can't tell you if it's a good or a bad idea. Theoretically speaking if the event comes from a click, I don't think that we can move forward with this proposition. If the event is backed by a native slider component, it could work out of the box. |
I had a quick look and it seems like material-ui is not using the native input type="range" under the hood, alternatives like rc-slider don't use it as well. Actually i didn't find an implementation which uses a native range input, so there might be a good reason to it. |
@sakulstra Then I guess we can label this issue "won't fix". |
should have looked a bit deeper - the libraries i checked support ie9+ (which doesn't support type="range") and have some more advanced range features(which will probably never be supported by material-ui itself anyways). So it might indeed make sense to use a range input under the hood. I actually just found a library using the range input: https://github.com/OnsenUI/OnsenUI/blob/master/core/src/elements/ons-range.js#L95 (never heard of it before though) |
I'm unfamiliar with the general course of action within the Material UI community about these types of issues... Are you both saying that Material UI isn't in the business of being opinionated about what types of events are emitted from the Material UI components that act as inputs, and that their handlers essentially act as passthroughs for native input elements? I just want to make sure I'm reading you correctly. If that's the case, then yes I would be a proponent of using the native range input if it makes sense, which will probably solve a whole class of issues of using this component alongside more traditional inputs in the future. |
@jonrhall Yes, it's what we have been trying to implement so far with all the components! |
Additionally currently there seems to be no way to get the value from onDragEnd and onDragStart events. Saving the value from onChangeState to inject it to onDragEnd feels redundant. If the onChangeState will be changed, those maybe should be changed as well. |
Expected Behavior
Currently, the
onChange
event parameters on theSlider
component are(event, value)
. While this works and is fine in and of itself, it is not consistent with the function parameters for otheronChange
events within the core Material UI library. For example, the v1TextField
component hasonChange
parameter of(event)
with the value of the event itself being bound in the nested propertyevent.target.value
, as does theSelect
component.The latter way of doing things seems to be "more correct". Doing it that way would help developers like myself generalize input behavior across different components (including
Slider
) that are used side-by-side.Current Behavior
Currently, the
onChange
event parameters on theSlider
component are(event, value)
.Steps to Reproduce (for bugs)
Just go to the first example on the Material UI website: https://material-ui.com/demos/selects/#simple-select
Context
I'm trying to tie a
TextField
component to aSlider
component so that the user has a choice over what input type to use. I have a generalhandleInput
method which takesevent.target.value
and assigns it to the state of my React component, which I would also like to use with theSelect
component but can't without first wrapping theonChange
event like so:Your Environment
The text was updated successfully, but these errors were encountered: