You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix object reference sharing in arrays with discriminated unions and minItems
Fixes#4756
When arrays with minItems > 0 were populated for discriminated unions (oneOf with discriminator),
the Array.fill() method created shared object references instead of independent instances.
This caused form field changes to affect multiple array items simultaneously.
Solution:
- Replace Array.fill() with Array.from() in getArrayDefaults function
- Array.from() creates independent object instances for each array item
- Maintains existing behavior while fixing the reference sharing bug
Added comprehensive test coverage for:
- Basic object independence in arrays
- Nested object scenarios
- Exact reproduction case from issue #4756
- Integration with discriminated union schemas
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,7 @@ should change the heading of the (upcoming) version to include a major version b
38
38
- BREAKING CHANGE: Removed `formContext` from the following interfaces because it is available on `registry`:
39
39
-`ErrorListProps`, `FieldProps`, `FieldTemplateProps`, `ArrayFieldTemplateProps` and `WidgetProps`
40
40
- Update `mergeDefaultsWithFormData` to properly handle overriding `undefined` formData with a `null` default value, fixing [#4734](https://github.com/rjsf-team/react-jsonschema-form/issues/4734)
41
+
- Fixed object reference sharing in arrays with minItems when using oneOf schemas, fixing [#4756](https://github.com/rjsf-team/react-jsonschema-form/issues/4756)
41
42
42
43
## Dev / docs / playground
43
44
@@ -234,7 +235,7 @@ should change the heading of the (upcoming) version to include a major version b
234
235
235
236
## @rjsf/mui
236
237
237
-
- Fixed build process to remove the `tsc-alias` replacer that was adding `/index.js` onto the `@mui/Xxxx` imports since MUI 7 has proper ESM support
238
+
- Fixed build process to remove the `tsc-alias` replacer that was adding `/index.js` onto the `@mui/Xxxx` imports since MUI 7 has proper ESM support
0 commit comments