Skip to content

Commit

Permalink
fix: auto save when component def changes (ToolJet#2638)
Browse files Browse the repository at this point in the history
* fix: auto save when component def changes

* remove callback
  • Loading branch information
gondar00 authored Mar 25, 2022
1 parent 2e62d74 commit d45ef48
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
5 changes: 3 additions & 2 deletions frontend/src/Editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,9 @@ class Editor extends React.Component {
},
this.handleAddPatch
);

return setStateAsync(_self, newDefinition);
setStateAsync(_self, newDefinition).then(() => {
this.autoSave();
});
};

cloneComponent = (newComponent) => {
Expand Down
48 changes: 24 additions & 24 deletions frontend/src/Editor/Inspector/Inspector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

childComponents.forEach((componentId) => {
let newChild = {
id: componentId,
...allComponents[componentId],
};

const { width, height } = newChild.layouts['desktop'];

newChild['layouts'] = {
...newChild.layouts,
mobile: {
top: 100,
left: 0,
width: Math.min(width, 445),
height: height,
},
};

componentDefinitionChanged(newChild);
});
componentDefinitionChanged(newComponent);

// Child componets should also have a mobile layout
const childComponents = Object.keys(allComponents).filter((key) => allComponents[key].parent === component.id);

childComponents.forEach((componentId) => {
let newChild = {
id: componentId,
...allComponents[componentId],
};

const { width, height } = newChild.layouts['desktop'];

newChild['layouts'] = {
...newChild.layouts,
mobile: {
top: 100,
left: 0,
width: Math.min(width, 445),
height: height,
},
};

componentDefinitionChanged(newChild);
});
}
}
Expand Down

0 comments on commit d45ef48

Please sign in to comment.