From 3b87a6dc13476fbef7e1b2efe90d925b365a13a2 Mon Sep 17 00:00:00 2001 From: francesco Date: Tue, 23 Apr 2024 16:07:02 +0200 Subject: [PATCH] Minor --- .../properties/BlockPropertyField.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/collection_editor/src/ui/collection_editor/properties/BlockPropertyField.tsx b/packages/collection_editor/src/ui/collection_editor/properties/BlockPropertyField.tsx index d94036f75..3aee412a7 100644 --- a/packages/collection_editor/src/ui/collection_editor/properties/BlockPropertyField.tsx +++ b/packages/collection_editor/src/ui/collection_editor/properties/BlockPropertyField.tsx @@ -2,11 +2,17 @@ import React, { useCallback, useState } from "react"; import { AddIcon, Button, Paper, Typography } from "@firecms/ui"; import { getIn, useFormex } from "@firecms/formex"; import { PropertyFormDialog } from "../PropertyEditView"; -import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util"; +import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util"; import { PropertyTree } from "../PropertyTree"; import { ArrayProperty, Property, PropertyConfig } from "@firecms/core"; -export function BlockPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: { +export function BlockPropertyField({ + disabled, + getData, + allowDataInference, + propertyConfigs, + collectionEditable + }: { disabled: boolean; getData?: () => Promise; allowDataInference: boolean; @@ -50,7 +56,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, prop setFieldValue(`oneOf.${idToPropertiesPath(fullId)}`, undefined, false); const propertiesOrderPath = `oneOf.${namespaceToPropertiesOrderPath(namespace)}`; - const currentPropertiesOrder: string[] = getIn(values, propertiesOrderPath); + const currentPropertiesOrder: string[] = getIn(values, propertiesOrderPath) ?? Object.keys(getIn(values, namespaceToPropertiesPath(namespace))); setFieldValue(propertiesOrderPath, currentPropertiesOrder.filter((p) => p !== propertyKey), false); setPropertyDialogOpen(false);