Open jasontkh opened 2 weeks ago
To also share my temporary fix:
basically I try to make sure the padding-*
properties sync with the padding
property when saving.
const fixComponent = useCallback((component: any) => {
if (component.style) {
if (component.style.padding) {
const parts = component.style.padding.split(' ');
component.style["padding-top"] = parts[0];
component.style["padding-right"] = parts[1];
component.style["padding-bottom"] = parts[2];
component.style["padding-left"] = parts[3];
}
}
if (component.attributes) {
if (component.attributes.padding) {
const parts = component.attributes.padding.split(' ');
component.attributes["padding-top"] = parts[0];
component.attributes["padding-right"] = parts[1];
component.attributes["padding-bottom"] = parts[2];
component.attributes["padding-left"] = parts[3];
component.attributes.style = Object.entries(component.attributes).filter(([key, value]) => key !== 'style').map(([key, value]) => `${key}:${value};`).join("");
}
}
if (component.components) {
component.components.forEach(fixComponent);
}
}, []);
const onSave = useCallback(async ({ project, editor }: { project: ProjectData, editor: Editor }) => {
project.pages.forEach((page: any) => {
page.frames.forEach((frame: any) => {
const component = frame.component;
fixComponent(component);
})
})
axios.post(....)
}, [campaignId, fixComponent]);
What browser are you using?
Firefox
Describe the bug
How to reproduce the bug?
What is the expected behavior? After save and load the padding remains the same
What is the current behavior? After save and load, the padding is reset to default. The bug happens only on some elements (Section, Text), some are fine (Column, Hero)
Investigation
The bug comes from different css attributes used. Here's a snippet from the saved data:
Whenever I change the padding of a Section (yes, Section has a problem, but Columns are fine), then save. 5 CSS attributes are exported:
padding
andpadding-*
. Whilepadding
contains the right CSS,padding-*
contains the default ones. Problem comes when the saved object is loaded again: the loading apparently readspadding-*
instead ofpadding
.Here's my code:
Code of Conduct