Reset selected component state to null when a component is deleted (#258)

This commit is contained in:
Prasad Walvekar 2021-06-15 23:41:48 +05:30 committed by GitHub
parent 582ac71973
commit a2b89ffe25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,6 +230,16 @@ class Editor extends React.Component {
this.computeComponentState(newDefinition.components);
};
handleInspectorView = (component) => {
if (this.state.selectedComponent.hasOwnProperty('component')) {
const { id: selectedComponentId } = this.state.selectedComponent;
if (selectedComponentId === component.id) {
this.setState({selectedComponent: null})
this.switchSidebarTab(2);
}
}
}
removeComponent = (component) => {
let newDefinition = this.state.appDefinition;
@ -241,7 +251,7 @@ class Editor extends React.Component {
delete newDefinition.components[component.id];
this.appDefinitionChanged(newDefinition);
this.switchSidebarTab(2);
this.handleInspectorView(component);
};
componentDefinitionChanged = (newDefinition) => {