-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formData includes undefined properties #3424
Comments
@AlexMunoz What happens if you use |
Hi @heath-freenome I think, liveOmit works in the case that the initial dataForm has an attribute that it not present in the schema. For example, if we have:
liveOmit will remove asfd because is not defined in the schema.
The problem that I've with RJSF after the 5.0.0-beta.19 version is that my formData is different after the initial mount.
After mount the formData will be:
Theoretically: I've also created a sample here: https://codesandbox.io/s/compare-objects-x3kwj4 |
Fixes: rjsf-team#3424 by preventing the inclusion of undefined properties at the root level - Updated `@rjsf/utils`, making `computDefaults` helper in `getDefaultFormState()` to skip adding undefined values when `excludeObjectChildren` is set. - This basically supports adding an empty object - Updated the tests accordingly - Updated the `CHANGELOG.md` accordingly
Fixes: rjsf-team#3424 by preventing the inclusion of undefined properties at the root level - Updated `@rjsf/utils`, making `computeDefaults` helper in `getDefaultFormState()` to skip adding undefined values when `excludeObjectChildren` is set. - This basically supports adding an empty object - Updated the tests accordingly - Updated the `CHANGELOG.md` accordingly
Fixes: rjsf-team#3424 by preventing the inclusion of undefined properties at the root level - Updated `@rjsf/utils`, making `computeDefaults` helper in `getDefaultFormState()` to skip adding undefined values when `excludeObjectChildren` is set. - This basically supports adding an empty object - Updated the tests accordingly - Updated the `CHANGELOG.md` accordingly - Also added information the changelog for PR rjsf-team#3202
Fixes: rjsf-team#3424 by preventing the inclusion of undefined properties at the root level - Updated `@rjsf/utils`, making `computeDefaults()` helper in `getDefaultFormState()` to skip adding undefined values when `allowEmptyObject` is set. - Updated the `getDefaultFormState()` definition in the `ValidatorType` to add this new option - Updated the tests accordingly - Updated `@rjsf/core`, switching the `excludeObjectChildren` with `allowEmptyObject` in `Form` - Updated the documentation for `getDefaultFormState()` to add this new option - Updated the `CHANGELOG.md` accordingly - Also added information the changelog for PR rjsf-team#3202
Fixes: rjsf-team#3424 by preventing the inclusion of undefined properties at the root level - Updated `@rjsf/utils`, making `computeDefaults()` helper in `getDefaultFormState()` to skip adding undefined values when `allowEmptyObject` is set. - Updated the `getDefaultFormState()` definition in the `ValidatorType` to add this new option - Updated the tests accordingly - Updated `@rjsf/core`, switching the `excludeObjectChildren` with `allowEmptyObject` in `Form` - Updated the documentation for `getDefaultFormState()` to add this new option - Updated the `CHANGELOG.md` accordingly - Also added information the changelog for PR rjsf-team#3202
* Fix: Prevent undefined properties at the root level Fixes: #3424 by preventing the inclusion of undefined properties at the root level - Updated `@rjsf/utils`, making `computeDefaults()` helper in `getDefaultFormState()` to skip adding undefined values when `allowEmptyObject` is set. - Updated the `getDefaultFormState()` definition in the `ValidatorType` to add this new option - Updated the tests accordingly - Updated `@rjsf/core`, switching the `excludeObjectChildren` with `allowEmptyObject` in `Form` - Updated the documentation for `getDefaultFormState()` to add this new option - Updated the `CHANGELOG.md` accordingly - Also added information the changelog for PR #3202 * - Responded to reviewer feedback
Prerequisites
What theme are you using?
core
Version
5.0.1
Current Behavior
Hello, I am migrating from a beta version to the release version of RJSF and I noticed that after beta.19 the formData object in the onChange and Submit event includes some undefined properties.
In version beta.19, the formData looks like:
and after beta.19, the formData looks like:
Expected Behavior
Only the fields I have changed are included in the formData.
Steps To Reproduce
Version 5.0.0-beta.19
https://codesandbox.io/s/rjsf-5-0-0-beta-19-ff6foc?file=/src/App.js
Version 5.0.1
https://codesandbox.io/s/rjsf-5-0-1-qhq3p6?file=/src/App.js
Environment
Anything else?
I am not sure if this behavior is expected. But it only occurs for properties at the first level, nested properties are not included as undefined.
why I need this: well I am doing a deep comparison between the current formData with the initial one, to detect if changes were made. If there is another way to check this, please let me know.
Update:
I think the change was introduced here: #3408
react-jsonschema-form/packages/core/src/components/Form.tsx
Lines 322 to 326 in 2e96fe2
The text was updated successfully, but these errors were encountered: