Skip to content

Array minItems not populated when default value is specified #3724

Open
@straygar

Description

@straygar

Prerequisites

What theme are you using?

core

Version

5.8.0

Current Behavior

Given a schema:

{
  "type": "object",
  "required": [
    "myProp"
  ],
  "properties": {
    "myProp": {
      "type": "array",
      "items": {
        "type": "string",
        "default": "abc"
      },
      "minItems": 1
    }
  }
}

And a form:

<Form
  schema={formSchema}
  experimental_defaultFormStateBehavior={{
    emptyObjectFields: 'populateRequiredDefaults',
    arrayMinItems: 'populate',
  }}
>

myProp is an empty array in the form.

Expected Behavior

myProp is prepopulated, i.e.:

{
  "myProp": [
    "abc"
  ]
}

Steps To Reproduce

  1. Open playground link
  2. Observe that the array is not prepopulated with "abc" as expected

Environment

- OS:
- Node:
- npm:

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions