-
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
Partially completed array values with minItems
get replaced by defaults
#3602
Comments
Similar test: it('should return partial array for an optional array property with minItems when provided with a partial array', () => {
const schema: RJSFSchema = {
type: 'object',
properties: {
optionalArray: {
type: 'array',
minItems: 2,
},
},
};
expect(
computeDefaults(testValidator, schema, {
rootSchema: schema,
rawFormData: { optionalArray: ['test'] },
behaviorBitFlags: DefaultFormStateBehavior.IgnoreMinItemsUnlessRequired,
})
).toEqual({ optionalArray: ['test'] });
}); Will fail with the returned value being |
Fixed by #3604 |
What should be the behavior for an optional array with no default value if we don't have a value for the array ? Here's the test:
|
@anthonycaron it's debatable honestly. I'm leaning towards expanding the new experimental behavior to give more control over the individual states as best we can. |
@heath-freenome Oh I didn't know about this. Sounds good, thanks for your feedback! |
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
If an array field has the
minItems
key set and has at least 1 less item than that, the values are replaced with the defaults. This only occurs when calling thecomputeDefaults
function directly, such as in a test-case.Expected Behavior
The existing form values are not replaced
Steps To Reproduce
main
packages/utils/test/schema/getDefaultFormStateTest.ts
:{ requiredArray: ['default0', 'default0'] }
Environment
Anything else?
This was encountered during work on an MR and was discussed with @heath-freenome. It seems like this doesn't actually affect the functionality of the form in a way I can replicate right now on the Playground, just when testing the
computeDefaults
function directly. Thus this is more of a placeholder/technical bug than one that is actively impacting the way the library works.Potentially related to #2980
The text was updated successfully, but these errors were encountered: