Skip to content

Commit acbd15c

Browse files
Fallback to keyCollectionDefinition if no collection items were found
1 parent 214f425 commit acbd15c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ export default class ComponentDataCollection extends Component {
6969
toJSON(opts?: ObjectAny) {
7070
const json = super.toJSON.call(this, opts) as ComponentDataCollectionDefinition;
7171

72-
const firstChild = this.getComponentDef();
73-
json[keyCollectionDefinition].componentDef = firstChild;
72+
const firstChildJSON = this.getComponentDef();
73+
json[keyCollectionDefinition].componentDef = firstChildJSON ?? this.get(keyCollectionDefinition);
7474

7575
delete json.components;
7676
delete json.droppable;
7777
return json;
7878
}
7979

8080
private getComponentDef() {
81-
const firstChildJSON = JSON.parse(JSON.stringify(this.components().at(0)));
82-
delete firstChildJSON.draggable;
81+
const firstChild = this.components().at(0);
82+
const firstChildJSON = firstChild?.toJSON();
83+
delete firstChildJSON?.draggable;
8384

8485
return firstChildJSON;
8586
}

0 commit comments

Comments
 (0)