Skip to content

Commit 8f0c11a

Browse files
Fix 4763 so that additional properties work properly again
Fixes #4763 by removing the `name` from the `path` passed to `onChange()` for additional properties callbacks - Updated `ObjectField` as described - Updated `Form` to not pass `idPrefix` as the `name` to avoid it showing up as the title of the schema - Updated `CHANGELOG.md` accordingly
1 parent 7e7c73c commit 8f0c11a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ should change the heading of the (upcoming) version to include a major version b
1717
-->
1818
# 6.0.0-beta.17
1919

20+
## @rjsf/core
21+
22+
- Updated `ObjectField` to remove the `name` from the path passed to `onChange()` callback in `handleAddClick()` and `onDropPropertyClick()`, fixing [#4763](https://github.com/rjsf-team/react-jsonschema-form/issues/4763)
23+
- Updated `Form` to restore the passing of an empty string for `name` to avoid accidentally showing it as the title for the whole schema
24+
2025
## @rjsf/shadcn
2126

22-
- Update ArrayFieldItemTemplate to align buttons with the input field [#4753](https://github.com/rjsf-team/react-jsonschema-form/pull/4753)
27+
- Update `ArrayFieldItemTemplate` to align buttons with the input field, fixing [#4753](https://github.com/rjsf-team/react-jsonschema-form/pull/4753)
2328

2429
# 6.0.0-beta.16
2530

packages/core/src/components/Form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ export default class Form<
11531153
>
11541154
{showErrorList === 'top' && this.renderErrors(registry)}
11551155
<_SchemaField
1156-
name={idPrefix}
1156+
name=''
11571157
schema={schema}
11581158
uiSchema={uiSchema}
11591159
errorSchema={errorSchema}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
9494
onDropPropertyClick = (key: string) => {
9595
return (event: DragEvent) => {
9696
event.preventDefault();
97-
const { onChange, formData, name } = this.props;
97+
const { onChange, formData } = this.props;
9898
const copiedFormData = { ...formData } as T;
9999
unset(copiedFormData, key);
100100
// drop property will pass the name in `path` array
101-
onChange(copiedFormData, [name]);
101+
onChange(copiedFormData, []);
102102
};
103103
};
104104

@@ -187,7 +187,7 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
187187
if (!(schema.additionalProperties || schema.patternProperties)) {
188188
return;
189189
}
190-
const { formData, name, onChange, registry } = this.props;
190+
const { formData, onChange, registry } = this.props;
191191
const newFormData = { ...formData } as T;
192192
const newKey = this.getAvailableKey('newKey', newFormData);
193193
if (schema.patternProperties) {
@@ -220,7 +220,7 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
220220
}
221221

222222
// add will pass the name in `path` array
223-
onChange(newFormData, [name]);
223+
onChange(newFormData, []);
224224
};
225225

226226
/** Renders the `ObjectField` from the given props

0 commit comments

Comments
 (0)