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
- In order to avoid regressions, added a new mergeDefaultsWithFormData prop to the Experimental_DefaultFormStateBehavior
- Updated `mergeDefaultsWithFormData()` to add new optional `defaultSupercedesUndefined` that when true uses the defaults rather than `undefined` formData
- Updated `getDefaultFormState()` to pass true to `mergeDefaultsWithFormData` for `defaultSupercedesUndefined` when `mergeDefaultsIntoFormData` has the value `useDefaultIfFormDataUndefined`
- Updated the documentation for the new capabilities
- Updated the playground to add controls for the new `mergeDefaultsIntoFormData` option
- moved the `Show Error List` component over one column, making it inline radio buttons rather than a select
Copy file name to clipboardExpand all lines: CHANGELOG.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,17 +16,26 @@ should change the heading of the (upcoming) version to include a major version b
16
16
17
17
-->
18
18
19
-
# 5.21.3
19
+
# 5.22.0
20
20
21
21
## @rjsf/core
22
22
23
-
- Updated `MultiSchemaField` to call the `onChange` handler after setting the new option, fixing [#3997](https://github.com/rjsf-team/react-jsonschema-form/issues/3977)
23
+
- Updated `MultiSchemaField` to call the `onChange` handler after setting the new option, fixing [#3997](https://github.com/rjsf-team/react-jsonschema-form/issues/3977) and [#4314](https://github.com/rjsf-team/react-jsonschema-form/issues/4314)
24
24
25
25
## @rjsf/utils
26
26
27
-
- Added `experimental_customMergeAllOf` option to `retrieveSchema` to allow custom merging of `allOf` schemas
28
-
- Updated `mergeDefaultsWithFormData()` to not merge `undefined` when there is a proper default for it, fixing [#4322](https://github.com/rjsf-team/react-jsonschema-form/issues/4322)
29
-
- Updated `getClosestMatchingOption()` to improve the scoring of sub-property objects that are provided over ones that aren't, fixing [#3997](https://github.com/rjsf-team/react-jsonschema-form/issues/3977)
27
+
- Added `experimental_customMergeAllOf` option to `retrieveSchema()` and `getDefaultFormState()` to allow custom merging of `allOf` schemas
28
+
- Added `mergeDefaultsIntoFormData` option to `Experimental_DefaultFormStateBehavior` type to control how to handle merging of defaults
29
+
- Updated `mergeDefaultsWithFormData()` to add new optional `defaultSupercedesUndefined` that when true uses the defaults rather than `undefined` formData, fixing [#4322](https://github.com/rjsf-team/react-jsonschema-form/issues/4322)
30
+
- Updated `getDefaultFormState()` to pass true to `mergeDefaultsWithFormData` for `defaultSupercedesUndefined` when `mergeDefaultsIntoFormData` has the value `useDefaultIfFormDataUndefined`, fixing [#4322](https://github.com/rjsf-team/react-jsonschema-form/issues/4322)
31
+
- Updated `getClosestMatchingOption()` to improve the scoring of sub-property objects that are provided over ones that aren't, fixing [#3997](https://github.com/rjsf-team/react-jsonschema-form/issues/3977) and [#4314](https://github.com/rjsf-team/react-jsonschema-form/issues/4314)
32
+
33
+
## Dev / docs / playground
34
+
35
+
- Updated the `form-props.md` to add documentation for the new `experimental_customMergeAllOf` props and the `experimental_defaultFormStateBehavior.mergeDefaultsIntoFormData` option
36
+
- Updated the `utility-functions.md` to add documentation for the new optional `defaultSupercedesUndefined` parameter and the two missing optional fields on `getDefaultFormState()`
37
+
- Updated the playground to add controls for the new `mergeDefaultsIntoFormData` option
38
+
- In the process, moved the `Show Error List` component over one column, making it inline radio buttons rather than a select
Copy file name to clipboardExpand all lines: packages/docs/docs/api-reference/form-props.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -251,6 +251,17 @@ render(
251
251
);
252
252
```
253
253
254
+
### mergeDefaultsIntoFormData
255
+
256
+
Optional enumerated flag controlling how the defaults are merged into the form data when dealing with undefined values, defaulting to `useFormDataIfPresent`.
257
+
258
+
NOTE: If there is a default for a field and the `formData` is unspecified, the default ALWAYS merges.
|`useFormDataIfPresent`| Legacy behavior - Do not merge defaults if there is a value for a field in `formData` even if that value is explicitly set to `undefined`|
263
+
|`useDefaultIfFormDataUndefined`| If the value of a field within the `formData` is `undefined`, then use the default value instead |
264
+
254
265
## experimental_customMergeAllOf
255
266
256
267
The `experimental_customMergeAllOf` function allows you to provide a custom implementation for merging `allOf` schemas. This can be particularly useful in scenarios where the default [json-schema-merge-allof](https://github.com/mokkabonna/json-schema-merge-allof) library becomes a performance bottleneck, especially with large and complex schemas or doesn't satisfy your needs.
Copy file name to clipboardExpand all lines: packages/docs/docs/api-reference/utility-functions.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -575,6 +575,7 @@ When merging defaults and form data, we want to merge in this specific way:
575
575
-[defaults]: T | undefined - The defaults to merge
576
576
-[formData]: T | undefined - The form data into which the defaults will be merged
577
577
-[mergeExtraArrayDefaults=false]: boolean - If true, any additional default array entries are appended onto the formData
578
+
-[defaultSupercedesUndefined=false]: boolean - If true, an explicit undefined value will be overwritten by the default value
578
579
579
580
#### Returns
580
581
@@ -897,6 +898,8 @@ Returns the superset of `formData` that includes the given set updated to includ
897
898
-[formData]: T | undefined - The current formData, if any, onto which to provide any missing defaults
898
899
-[rootSchema]: S | undefined - The root schema, used to primarily to look up `$ref`s
899
900
-[includeUndefinedValues=false]: boolean | "excludeObjectChildren" - Optional flag, if true, cause undefined values to be added as defaults. If "excludeObjectChildren", cause undefined values for this object and pass `includeUndefinedValues` as false when computing defaults for any nested object properties.
901
+
-[experimental_defaultFormStateBehavior]: Experimental_DefaultFormStateBehavior - See Form props [experimental_defaultFormStateBehavior documentation](./api-reference/form-props.md#experimental_defaultFormStateBehavior)
902
+
-[experimental_customMergeAllOf]: Experimental_CustomMergeAllOf<S> - See Form props [experimental_customMergeAllOf documentation](./api-reference/form-props.md#experimental_customMergeAllOf)
0 commit comments