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 4821 by no saving undefined values into an object for a null type field (#4839)
* Fix 4821 by no saving undefined values into an object for a null type field
Fixed#4821 by not saving an undefined field value into an object when that field has the `null` type
- Updated `getDefaultFormState()` to not save an undefined field value into an object when the type is `null` and `excludeObjectChildren` is provided
- Updated the tests to verify this new fix
- Updated the `CHANGELOG.md` accordingly
# Conflicts:
# CHANGELOG.md
* - Responded to reviewer feedback
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,10 @@ should change the heading of the (upcoming) version to include a major version b
60
60
61
61
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
62
62
63
+
## @rjsf/utils
64
+
65
+
- Updated `getDefaultFormState()` to not save an undefined field value into an object when the type is `null` and `excludeObjectChildren` is provided, fixing [#4821](https://github.com/rjsf-team/react-jsonschema-form/issues/4821)
66
+
63
67
## Dev / docs / playground
64
68
65
69
- Updated the `OptionsDrawer` of the playground to add `idPrefix` and `idSeparator` fields
Copy file name to clipboardExpand all lines: packages/utils/src/schema/getDefaultFormState.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,7 @@ export function computeDefaultBasedOnSchemaTypeAndDefaults<T = any, S extends St
121
121
* @param experimental_defaultFormStateBehavior - Optional configuration object, if provided, allows users to override
122
122
* default form state behavior
123
123
* @param isConst - Optional flag, if true, indicates that the schema has a const property defined, thus we should always return the computedDefault since it's coming from the const.
124
+
* @param isNullType - The type of the schema is null
124
125
*/
125
126
functionmaybeAddDefaultToObject<T=any>(
126
127
obj: GenericObjectType,
@@ -131,6 +132,7 @@ function maybeAddDefaultToObject<T = any>(
0 commit comments