Skip to content
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

fix(utils): omit computedDefault of empty required properties nested in optional parent property #3287

Conversation

zmagauina-fn
Copy link
Contributor

Reasons for making this change

Continuing from this PR: fix(utils): omit computedDefault of empty objects
Fixes #2150 and #2708.

Checklist

  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR

@zmagauina-fn zmagauina-fn marked this pull request as ready for review December 7, 2022 20:57
Copy link
Member

@heath-freenome heath-freenome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the CHANGELOG.md

packages/validator-ajv8/src/validator.ts Outdated Show resolved Hide resolved
packages/validator-ajv6/src/validator.ts Outdated Show resolved Hide resolved
packages/utils/src/types.ts Outdated Show resolved Hide resolved
packages/utils/src/schema/getDefaultFormState.ts Outdated Show resolved Hide resolved
packages/utils/src/schema/getDefaultFormState.ts Outdated Show resolved Hide resolved
packages/utils/src/schema/getDefaultFormState.ts Outdated Show resolved Hide resolved
packages/utils/src/createSchemaUtils.ts Outdated Show resolved Hide resolved
packages/core/src/components/fields/MultiSchemaField.tsx Outdated Show resolved Hide resolved
docs/api-reference/utility-functions.md Outdated Show resolved Hide resolved
@heath-freenome
Copy link
Member

heath-freenome commented Dec 7, 2022

I'm actually not sure noRecursion is the best suggested change. What this new option is doing is to prevent recursively passing true for every level of an object in the case where you need an empty object value, but not the undefined properties inside of that object

@nickgros
Copy link
Contributor

nickgros commented Dec 8, 2022

I'm actually not sure noRecursion is the best suggested change. What this new option is doing is to prevent recursively passing true for every level of an object in the case where you need an empty object value, but not the undefined properties of inside of that object

We could go with excludeObjectFields or excludeObjectChildren, if that makes sense?

@heath-freenome
Copy link
Member

Also, please update the CHANGELOG.md

@zmagauina-fn zmagauina-fn force-pushed the fix-getDefaultFormState-for-nested-optional-properties branch from 07180ca to 0ed7122 Compare December 8, 2022 21:29
@zmagauina-fn zmagauina-fn force-pushed the fix-getDefaultFormState-for-nested-optional-properties branch from 0ed7122 to d1c69f7 Compare December 8, 2022 21:37
…deUndefinedValues prop as "excludeObjectChildren"
@heath-freenome heath-freenome merged commit dc19858 into rjsf-team:main Dec 8, 2022
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this pull request Jun 8, 2023
…in optional parent property (rjsf-team#3287)

* fix(utils): omit computedDefault of empty required properties nested in optional parent property

* responding to feedback - updated once to excludeObjectChildren, updated changelog

* Add comment into MultiSchemaField to explain reason for passing includeUndefinedValues prop as "excludeObjectChildren"
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this pull request Jun 8, 2023
…in optional parent property (rjsf-team#3287)

* fix(utils): omit computedDefault of empty required properties nested in optional parent property

* responding to feedback - updated once to excludeObjectChildren, updated changelog

* Add comment into MultiSchemaField to explain reason for passing includeUndefinedValues prop as "excludeObjectChildren"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-required object field can't be left empty if at least one its property is required.
3 participants