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 behaviour of arrays with minItems and default #663

Merged
merged 1 commit into from
Aug 9, 2017

Conversation

spacebaboon
Copy link
Contributor

@spacebaboon spacebaboon commented Aug 9, 2017

Reasons for making this change

When providing both default (as a list) and minItems to a field of type array
the defaults are treated as a single value that ends up in each field.

This is a repost of PR #655 which got accidentally deleted and automatically closed, and updated to fix conflict with master.

Relates to ticket
#631

Expected behavior

defaults should be treated as a list and be given one entry each, i.e.:

When minItems > default.length provide empty or item-level default fields after the fields with the default values.
When minItems <= default.length provide one field per value in default list.

Actual behavior

The default items gets mashed together into each field

Checklist

  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

Fix bug whereby defaults in an array were munged together and added to extra item's formData.
Behaviour now is to fill the array with the object level default array, and then add extra items up to minItems.
These extra items will be either empty or the item-level default.
Added demonstration of this in the Arrays tab of the playground.
Copy link
Collaborator

@n1k0 n1k0 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for contributing.

@glasserc
Copy link
Contributor

glasserc commented Sep 6, 2017

Released in v0.50.0.

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.

None yet

3 participants