Skip to content

Commit

Permalink
Fix #1163: In scene, when deleting a trigger, it should not mix devic…
Browse files Browse the repository at this point in the history
…e feature data

Co-authored-by: Pierre-Gilles Leymarie <pierregilles.leymarie@gmail.com>
  • Loading branch information
atrovato and Pierre-Gilles committed Sep 10, 2021
1 parent b68d47f commit 64d1bb5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions front/src/components/device/SelectDeviceFeature.jsx
Expand Up @@ -52,12 +52,6 @@ class SelectDeviceFeature extends Component {
});
await this.setState({ deviceOptions, deviceFeaturesDictionnary, deviceDictionnary });
await this.refreshSelectedOptions(this.props);
if (this.state.selectedOption && this.state.selectedOption.value) {
this.props.onDeviceFeatureChange(
deviceFeaturesDictionnary[this.state.selectedOption.value],
deviceDictionnary[this.state.selectedOption.value]
);
}
return deviceOptions;
} catch (e) {
console.error(e);
Expand All @@ -76,6 +70,7 @@ class SelectDeviceFeature extends Component {
};
refreshSelectedOptions = async nextProps => {
let selectedOption = '';
const { selectedOption: originalSelected } = this.state;
if (nextProps.value && this.state.deviceOptions) {
let deviceOption;
let i = 0;
Expand All @@ -88,7 +83,19 @@ class SelectDeviceFeature extends Component {
selectedOption = deviceOption;
}
}

await this.setState({ selectedOption });

if (originalSelected !== selectedOption) {
if (selectedOption) {
this.props.onDeviceFeatureChange(
this.state.deviceFeaturesDictionnary[selectedOption.value],
this.state.deviceDictionnary[selectedOption.value]
);
} else {
this.props.onDeviceFeatureChange(null, null);
}
}
};
constructor(props) {
super(props);
Expand Down

0 comments on commit 64d1bb5

Please sign in to comment.