Skip to content

Commit 3b87a6d

Browse files
committed
Minor
1 parent 2eb3dff commit 3b87a6d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/collection_editor/src/ui/collection_editor/properties/BlockPropertyField.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import React, { useCallback, useState } from "react";
22
import { AddIcon, Button, Paper, Typography } from "@firecms/ui";
33
import { getIn, useFormex } from "@firecms/formex";
44
import { PropertyFormDialog } from "../PropertyEditView";
5-
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
5+
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
66
import { PropertyTree } from "../PropertyTree";
77
import { ArrayProperty, Property, PropertyConfig } from "@firecms/core";
88

9-
export function BlockPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
9+
export function BlockPropertyField({
10+
disabled,
11+
getData,
12+
allowDataInference,
13+
propertyConfigs,
14+
collectionEditable
15+
}: {
1016
disabled: boolean;
1117
getData?: () => Promise<object[]>;
1218
allowDataInference: boolean;
@@ -50,7 +56,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, prop
5056

5157
setFieldValue(`oneOf.${idToPropertiesPath(fullId)}`, undefined, false);
5258
const propertiesOrderPath = `oneOf.${namespaceToPropertiesOrderPath(namespace)}`;
53-
const currentPropertiesOrder: string[] = getIn(values, propertiesOrderPath);
59+
const currentPropertiesOrder: string[] = getIn(values, propertiesOrderPath) ?? Object.keys(getIn(values, namespaceToPropertiesPath(namespace)));
5460
setFieldValue(propertiesOrderPath, currentPropertiesOrder.filter((p) => p !== propertyKey), false);
5561

5662
setPropertyDialogOpen(false);

0 commit comments

Comments
 (0)