@@ -2,11 +2,17 @@ import React, { useCallback, useState } from "react";
2
2
import { AddIcon , Button , Paper , Typography } from "@firecms/ui" ;
3
3
import { getIn , useFormex } from "@firecms/formex" ;
4
4
import { PropertyFormDialog } from "../PropertyEditView" ;
5
- import { getFullId , idToPropertiesPath , namespaceToPropertiesOrderPath } from "../util" ;
5
+ import { getFullId , idToPropertiesPath , namespaceToPropertiesOrderPath , namespaceToPropertiesPath } from "../util" ;
6
6
import { PropertyTree } from "../PropertyTree" ;
7
7
import { ArrayProperty , Property , PropertyConfig } from "@firecms/core" ;
8
8
9
- export function BlockPropertyField ( { disabled, getData, allowDataInference, propertyConfigs, collectionEditable } : {
9
+ export function BlockPropertyField ( {
10
+ disabled,
11
+ getData,
12
+ allowDataInference,
13
+ propertyConfigs,
14
+ collectionEditable
15
+ } : {
10
16
disabled : boolean ;
11
17
getData ?: ( ) => Promise < object [ ] > ;
12
18
allowDataInference : boolean ;
@@ -50,7 +56,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, prop
50
56
51
57
setFieldValue ( `oneOf.${ idToPropertiesPath ( fullId ) } ` , undefined , false ) ;
52
58
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 ) ) ) ;
54
60
setFieldValue ( propertiesOrderPath , currentPropertiesOrder . filter ( ( p ) => p !== propertyKey ) , false ) ;
55
61
56
62
setPropertyDialogOpen ( false ) ;
0 commit comments