Skip to content

Commit 4ae0e7e

Browse files
committed
Ensure that uiSchema updates correctly when changing type
1 parent b2fda63 commit 4ae0e7e

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/formBuilder/utils.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -879,23 +879,14 @@ export function updateSchemas(
879879
generateSchemaFromElementProps(elementArr),
880880
);
881881

882-
const existingUiSchema: {
882+
const newUiSchema: {
883883
[string]: any,
884884
definitions?: { [string]: any },
885885
...
886-
} = Object.entries(uischema)
887-
.filter(([key, _value]) => {
888-
return key in newSchema.properties || key.startsWith('ui:');
889-
})
890-
.reduce((accumulator, currentValue) => {
891-
const [key, value] = currentValue;
892-
return { ...accumulator, [key]: value };
893-
}, {});
894-
895-
const newUiSchema = Object.assign(
896-
{ ...existingUiSchema },
897-
generateUiSchemaFromElementProps(elementArr, definitionUi),
898-
);
886+
} = generateUiSchemaFromElementProps(elementArr, definitionUi);
887+
if (uischema.definitions) {
888+
newUiSchema.definitions = uischema.definitions;
889+
}
899890

900891
// mandate that the type is an object if not already done
901892
newSchema.type = 'object';

0 commit comments

Comments
 (0)