Skip to content

[slider] Normalize onChange event parameters #11990

Description

@jonrhall
  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Currently, the onChange event parameters on the Slider component are (event, value). While this works and is fine in and of itself, it is not consistent with the function parameters for other onChange events within the core Material UI library. For example, the v1 TextField component has onChange parameter of (event) with the value of the event itself being bound in the nested property event.target.value, as does the Select 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 the Slider 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 a Slider component so that the user has a choice over what input type to use. I have a general handleInput method which takes event.target.value and assigns it to the state of my React component, which I would also like to use with the Select component but can't without first wrapping the onChange event like so:

onChange={(event, val) => this.handleInput({ event: { target: { value: val } } })}

Your Environment

Tech Version
Material-UI v1.1.0
React v16.4.0
material-ui/lab v1.0.0-alpha.5

Metadata

Metadata

Labels

scope: sliderChanges related to the slider.type: bugIt doesn't behave as expected.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions