fix: auto save when component def changes (#2638)

* fix: auto save when component def changes

* remove callback
This commit is contained in:
Gandharv 2022-03-25 17:40:32 +05:00 committed by GitHub
parent 2e62d7480a
commit d45ef4865e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 22 deletions

View file

@ -503,8 +503,9 @@ class Editor extends React.Component {
},
this.handleAddPatch
);
return setStateAsync(_self, newDefinition);
setStateAsync(_self, newDefinition).then(() => {
this.autoSave();
});
};
cloneComponent = (newComponent) => {

View file

@ -162,30 +162,30 @@ export const Inspector = ({
},
};
componentDefinitionChanged(newComponent).then(() => {
// Child componets should also have a mobile layout
const childComponents = Object.keys(allComponents).filter((key) => allComponents[key].parent === component.id);
componentDefinitionChanged(newComponent);
childComponents.forEach((componentId) => {
let newChild = {
id: componentId,
...allComponents[componentId],
};
// Child componets should also have a mobile layout
const childComponents = Object.keys(allComponents).filter((key) => allComponents[key].parent === component.id);
const { width, height } = newChild.layouts['desktop'];
childComponents.forEach((componentId) => {
let newChild = {
id: componentId,
...allComponents[componentId],
};
newChild['layouts'] = {
...newChild.layouts,
mobile: {
top: 100,
left: 0,
width: Math.min(width, 445),
height: height,
},
};
const { width, height } = newChild.layouts['desktop'];
componentDefinitionChanged(newChild);
});
newChild['layouts'] = {
...newChild.layouts,
mobile: {
top: 100,
left: 0,
width: Math.min(width, 445),
height: height,
},
};
componentDefinitionChanged(newChild);
});
}
}