Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaejoon-daim committed May 3, 2024
1 parent e7b8277 commit 0d8d955
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/components/fields/ObjectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TranslatableString,
ADDITIONAL_PROPERTY_FLAG,
PROPERTIES_KEY,
DEFAULT_KEY,
REF_KEY,
ANY_OF_KEY,
ONE_OF_KEY,
Expand Down Expand Up @@ -137,7 +138,7 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
if (oldValue === value) {
return;
}
const { formData, onChange, errorSchema } = this.props;
const { formData, onChange, errorSchema, schema } = this.props;

value = this.getAvailableKey(value, formData);
const newFormData: GenericObjectType = {
Expand All @@ -152,6 +153,12 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo

this.setState({ wasPropertyKeyModified: true });

if (DEFAULT_KEY in schema) {
const defaults = schema[DEFAULT_KEY] as GenericObjectType;
unset(defaults, oldValue);
set(defaults, value, newFormData[oldValue]);
}

onChange(
renamedObj,
errorSchema &&
Expand Down

0 comments on commit 0d8d955

Please sign in to comment.