diff --git a/frontend/packages/ux-editor/src/utils/dataModelUtils.test.ts b/frontend/packages/ux-editor/src/utils/dataModelUtils.test.ts index c958346031d..f8b4b5aecff 100644 --- a/frontend/packages/ux-editor/src/utils/dataModelUtils.test.ts +++ b/frontend/packages/ux-editor/src/utils/dataModelUtils.test.ts @@ -281,4 +281,13 @@ describe('getDataModel', () => { const dataModel = getDataModel(isDataModelValid, dataModelMetadata, currentDataModel); expect(dataModel).toEqual(currentDataModel); }); + + it('should return default data model if current data model is empty string', () => { + const isDataModelValid = true; + const currentDataModel = ''; + const dataModelMetadata = dataModelMetadataMock; + + const dataModel = getDataModel(isDataModelValid, dataModelMetadata, currentDataModel); + expect(dataModel).toEqual(defaultModel); + }); }); diff --git a/frontend/packages/ux-editor/src/utils/dataModelUtils.ts b/frontend/packages/ux-editor/src/utils/dataModelUtils.ts index cb30f37a5c2..9349212e4d2 100644 --- a/frontend/packages/ux-editor/src/utils/dataModelUtils.ts +++ b/frontend/packages/ux-editor/src/utils/dataModelUtils.ts @@ -145,7 +145,7 @@ export const getDataModel = ( currentDataModel?: string, ): string => { if (dataModelMetadata) { - return isDataModelValid && currentDataModel !== undefined + return isDataModelValid && currentDataModel !== undefined && currentDataModel !== '' ? currentDataModel : dataModelMetadata[0]?.id; }