Skip to content

Commit 0d8d955

Browse files
committed
1 parent e7b8277 commit 0d8d955

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/core/src/components/fields/ObjectField.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
TranslatableString,
1414
ADDITIONAL_PROPERTY_FLAG,
1515
PROPERTIES_KEY,
16+
DEFAULT_KEY,
1617
REF_KEY,
1718
ANY_OF_KEY,
1819
ONE_OF_KEY,
@@ -137,7 +138,7 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
137138
if (oldValue === value) {
138139
return;
139140
}
140-
const { formData, onChange, errorSchema } = this.props;
141+
const { formData, onChange, errorSchema, schema } = this.props;
141142

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

153154
this.setState({ wasPropertyKeyModified: true });
154155

156+
if (DEFAULT_KEY in schema) {
157+
const defaults = schema[DEFAULT_KEY] as GenericObjectType;
158+
unset(defaults, oldValue);
159+
set(defaults, value, newFormData[oldValue]);
160+
}
161+
155162
onChange(
156163
renamedObj,
157164
errorSchema &&

0 commit comments

Comments
 (0)