fix bug introduced in value change code

This commit is contained in:
Rick Watson 2019-08-09 21:26:31 +01:00
parent 391fe85a4b
commit cf48c79b4d
2 changed files with 12 additions and 5 deletions

View File

@ -89,7 +89,13 @@ export const restComponent = (endpointUrl, FormComponent) => {
});
}
handleValueChange = name => (event, newValue) => {
handleValueChange = name => (event) => {
const { data } = this.state;
data[name] = event.target.value;
this.setState({ data });
};
handleSliderChange = name => (event, newValue) => {
const { data } = this.state;
data[name] = newValue;
this.setState({ data });
@ -105,6 +111,7 @@ export const restComponent = (endpointUrl, FormComponent) => {
return <FormComponent
handleValueChange={this.handleValueChange}
handleCheckboxChange={this.handleCheckboxChange}
handleSliderChange={this.handleSliderChange}
setData={this.setData}
saveData={this.saveData}
loadData={this.loadData}

View File

@ -21,7 +21,7 @@ class DemoController extends Component {
}
render() {
const { data, fetched, errorMessage, saveData, loadData, handleValueChange } = this.props;
const { data, fetched, errorMessage, saveData, loadData, handleSliderChange } = this.props;
return (
<SectionContent title="Controller" titleGutter>
<LoadingNotification
@ -33,7 +33,7 @@ class DemoController extends Component {
demoSettings={data}
onReset={loadData}
onSubmit={saveData}
handleValueChange={handleValueChange}
handleSliderChange={handleSliderChange}
/>
}
/>
@ -53,7 +53,7 @@ const useStyles = makeStyles(theme => ({
}));
function DemoControllerForm(props) {
const { demoSettings, onSubmit, onReset, handleValueChange } = props;
const { demoSettings, onSubmit, onReset, handleSliderChange } = props;
const classes = useStyles();
return (
<ValidatorForm onSubmit={onSubmit}>
@ -67,7 +67,7 @@ function DemoControllerForm(props) {
valueLabelDisplay="on"
min={0}
max={255}
onChange={handleValueChange('blink_speed')}
onChange={handleSliderChange('blink_speed')}
/>
<Button variant="contained" color="primary" className={classes.button} type="submit">
Save