Skip to content

Commit cf48c79

Browse files
committed
fix bug introduced in value change code
1 parent 391fe85 commit cf48c79

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

interface/src/components/RestComponent.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ export const restComponent = (endpointUrl, FormComponent) => {
8989
});
9090
}
9191

92-
handleValueChange = name => (event, newValue) => {
92+
handleValueChange = name => (event) => {
93+
const { data } = this.state;
94+
data[name] = event.target.value;
95+
this.setState({ data });
96+
};
97+
98+
handleSliderChange = name => (event, newValue) => {
9399
const { data } = this.state;
94100
data[name] = newValue;
95101
this.setState({ data });
@@ -105,6 +111,7 @@ export const restComponent = (endpointUrl, FormComponent) => {
105111
return <FormComponent
106112
handleValueChange={this.handleValueChange}
107113
handleCheckboxChange={this.handleCheckboxChange}
114+
handleSliderChange={this.handleSliderChange}
108115
setData={this.setData}
109116
saveData={this.saveData}
110117
loadData={this.loadData}

interface/src/project/DemoController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DemoController extends Component {
2121
}
2222

2323
render() {
24-
const { data, fetched, errorMessage, saveData, loadData, handleValueChange } = this.props;
24+
const { data, fetched, errorMessage, saveData, loadData, handleSliderChange } = this.props;
2525
return (
2626
<SectionContent title="Controller" titleGutter>
2727
<LoadingNotification
@@ -33,7 +33,7 @@ class DemoController extends Component {
3333
demoSettings={data}
3434
onReset={loadData}
3535
onSubmit={saveData}
36-
handleValueChange={handleValueChange}
36+
handleSliderChange={handleSliderChange}
3737
/>
3838
}
3939
/>
@@ -53,7 +53,7 @@ const useStyles = makeStyles(theme => ({
5353
}));
5454

5555
function DemoControllerForm(props) {
56-
const { demoSettings, onSubmit, onReset, handleValueChange } = props;
56+
const { demoSettings, onSubmit, onReset, handleSliderChange } = props;
5757
const classes = useStyles();
5858
return (
5959
<ValidatorForm onSubmit={onSubmit}>
@@ -67,7 +67,7 @@ function DemoControllerForm(props) {
6767
valueLabelDisplay="on"
6868
min={0}
6969
max={255}
70-
onChange={handleValueChange('blink_speed')}
70+
onChange={handleSliderChange('blink_speed')}
7171
/>
7272
<Button variant="contained" color="primary" className={classes.button} type="submit">
7373
Save

0 commit comments

Comments
 (0)