Browse Source

Update the logic for getComponentDef

collection-component
mohamedsalem401 2 years ago
parent
commit
214f42551e
  1. 7
      packages/core/src/data_sources/model/data_collection/ComponentDataCollection.ts

7
packages/core/src/data_sources/model/data_collection/ComponentDataCollection.ts

@ -78,12 +78,7 @@ export default class ComponentDataCollection extends Component {
} }
private getComponentDef() { private getComponentDef() {
const firstChild = this.components().at(0); const firstChildJSON = JSON.parse(JSON.stringify(this.components().at(0)));
const firstChildJSON = firstChild?.toJSON() ?? {};
const shouldHaveChildren = firstChild && !firstChild.get(keyCollectionDefinition) && firstChild.components().length;
if (shouldHaveChildren) {
firstChildJSON.components = firstChild.components().map((component) => component.toJSON());
}
delete firstChildJSON.draggable; delete firstChildJSON.draggable;
return firstChildJSON; return firstChildJSON;

Loading…
Cancel
Save