From 86b625699592f50899e79cd4aa2dfa21f5a5fad1 Mon Sep 17 00:00:00 2001 From: francesco Date: Thu, 12 Dec 2024 16:34:08 +0100 Subject: [PATCH] Fix for default values bug in undefined properties --- packages/firecms_core/src/util/entities.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/firecms_core/src/util/entities.ts b/packages/firecms_core/src/util/entities.ts index c6a2c5388..17e72b1e1 100644 --- a/packages/firecms_core/src/util/entities.ts +++ b/packages/firecms_core/src/util/entities.ts @@ -40,13 +40,15 @@ export function getDefaultValuesFor>(properties: P if (!properties) return {}; return Object.entries(properties) .map(([key, property]) => { + if (!property) return {}; const value = getDefaultValueFor(property as PropertyOrBuilder); return value === undefined ? {} : { [key]: value }; }) .reduce((a, b) => ({ ...a, ...b }), {}) as EntityValues; } -export function getDefaultValueFor(property: PropertyOrBuilder) { +export function getDefaultValueFor(property?: PropertyOrBuilder) { + if (!property) return undefined; if (isPropertyBuilder(property)) return undefined; if (property.defaultValue || property.defaultValue === null) { return property.defaultValue;