From 8f0c11ab470550c18de414234b0ad18f46d24b19 Mon Sep 17 00:00:00 2001 From: Heath Chiavettone Date: Fri, 12 Sep 2025 12:50:28 -0700 Subject: [PATCH] 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 --- CHANGELOG.md | 7 ++++++- packages/core/src/components/Form.tsx | 2 +- packages/core/src/components/fields/ObjectField.tsx | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbad7c19e2..20ab6f430a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,9 +17,14 @@ should change the heading of the (upcoming) version to include a major version b --> # 6.0.0-beta.17 +## @rjsf/core + +- 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) +- Updated `Form` to restore the passing of an empty string for `name` to avoid accidentally showing it as the title for the whole schema + ## @rjsf/shadcn -- Update ArrayFieldItemTemplate to align buttons with the input field [#4753](https://github.com/rjsf-team/react-jsonschema-form/pull/4753) +- Update `ArrayFieldItemTemplate` to align buttons with the input field, fixing [#4753](https://github.com/rjsf-team/react-jsonschema-form/pull/4753) # 6.0.0-beta.16 diff --git a/packages/core/src/components/Form.tsx b/packages/core/src/components/Form.tsx index f56b973011..85ed258503 100644 --- a/packages/core/src/components/Form.tsx +++ b/packages/core/src/components/Form.tsx @@ -1153,7 +1153,7 @@ export default class Form< > {showErrorList === 'top' && this.renderErrors(registry)} <_SchemaField - name={idPrefix} + name='' schema={schema} uiSchema={uiSchema} errorSchema={errorSchema} diff --git a/packages/core/src/components/fields/ObjectField.tsx b/packages/core/src/components/fields/ObjectField.tsx index d054571e33..4cd61d4133 100644 --- a/packages/core/src/components/fields/ObjectField.tsx +++ b/packages/core/src/components/fields/ObjectField.tsx @@ -94,11 +94,11 @@ class ObjectField { return (event: DragEvent) => { event.preventDefault(); - const { onChange, formData, name } = this.props; + const { onChange, formData } = this.props; const copiedFormData = { ...formData } as T; unset(copiedFormData, key); // drop property will pass the name in `path` array - onChange(copiedFormData, [name]); + onChange(copiedFormData, []); }; }; @@ -187,7 +187,7 @@ class ObjectField