Skip to content

bug: group-array only supports an array of objects #21

@juicycleff

Description

@juicycleff
Screenshot 2023-06-23 at 11 13 04
{
  $schema: 'http://json-schema.org/draft-04/schema#',
  $id: 'https://example.com/employee.schema.json',
  title: 'Input',
  description: 'Soooooooo meee',
  type: 'object',
  properties: {
    id: {
      description: 'A unique identifier for an employee',
      type: 'number',
    },
    name: {
      description: 'Full name of the employee',
      type: 'string',
    },
    age: {
      description: 'Age of the employee',
      placeholder: 'Age of the employee',
      type: 'number',
    },
    maggies: {
      description: 'maggies of the employee',
      type: 'object',
      properties: {
        name: {
          description: 'Full name of the employee',
          type: 'string',
        },
        age: {
          description: 'Age of the employee',
          placeholder: 'Age of the employee',
          type: 'number',
        },
      },
    },
    dependent_details: {
      items: {
        properties: {
          birthdate: {
            description: 'Enter your child’s date of birth',
            format: 'date',
            'x-jsf-presentation': {
              inputType: 'date',
            },
            title: 'Child Birthdate',
            type: 'string',
            maxLength: 255,
          },
          full_name: {
            description: 'Enter your child’s full name',
            'x-jsf-presentation': {
              inputType: 'text',
            },
            title: 'Child Full Name',
            type: 'string',
            maxLength: 255,
          },
          sex: {
            description:
              'We know sex is non-binary but for insurance and payroll purposes, we need to collect this information.',
            enum: ['female', 'male'],
            'x-jsf-presentation': {
              inputType: 'radio',
              options: [
                {
                  label: 'Male',
                  value: 'male',
                },
                {
                  label: 'Female',
                  value: 'female',
                },
              ],
            },
            title: 'Child Sex',
          },
        },
        'x-jsf-order': ['full_name', 'birthdate', 'sex'],
        required: ['full_name', 'birthdate', 'sex'],
        type: 'object',
      },
      'x-jsf-presentation': {
        inputType: 'group-array',
        addFieldText: 'Add new field',
      },
      title: 'Child details',
      description: 'Add the dependents you claim below',
      type: 'array',
    },
    optional_dependent_details: {
      items: {
        properties: {
          birthdate: {
            description: 'Enter your child’s date of birth',
            format: 'date',
            'x-jsf-presentation': {
              inputType: 'date',
            },
            title: 'Child Birthdate',
            type: 'string',
            maxLength: 255,
          },
          full_name: {
            description: 'Enter your child’s full name',
            'x-jsf-presentation': {
              inputType: 'text',
            },
            title: 'Child Full Name',
            type: 'string',
            maxLength: 255,
          },
          sex: {
            description:
              'We know sex is non-binary but for insurance and payroll purposes, we need to collect this information.',
            enum: ['female', 'male'],
            'x-jsf-presentation': {
              inputType: 'radio',
              options: [
                {
                  label: 'Male',
                  value: 'male',
                },
                {
                  label: 'Female',
                  value: 'female',
                },
              ],
            },
            title: 'Child Sex',
          },
        },
        'x-jsf-order': ['full_name', 'birthdate', 'sex'],
        required: ['full_name', 'birthdate', 'sex'],
        type: 'object',
      },
      'x-jsf-presentation': {
        inputType: 'group-array',
        addFieldText: 'Add new field',
      },
      title: 'Child details (optional)',
      description:
        'This is an optional group-array. For a better UX, this Component asks a Yes/No question before allowing to add new field entries.',
      type: 'array',
    },
    hobbies: {
      description: 'Hobbies of the employee',
      type: 'object',
      properties: {
        indoor: {
          type: 'array',
          items: {
            'x-jsf-presentation': {
              inputType: 'text',
            },
            description: 'List of indoor hobbies',
            type: 'string',
          },
        },
        outdoor: {
          type: 'array',
          title: 'Child details',
          description: 'List of outdoor hobbies',
          items: {
            description: 'List of outdoor hobbies',
            type: 'object',
            properties: {
              indoor: {
                type: 'array',
                items: {
                  description: 'List of indoor hobbies',
                  type: 'string',
                },
              },
              outdoor: {
                type: 'array',
                items: {
                  description: 'List of outdoor hobbies',
                  type: 'string',
                },
              },
            },
          },
        },
        maggies: {
          description: 'Hobbies of the employee',
          type: 'object',
          properties: {
            indoor: {
              type: 'array',
              items: {
                description: 'List of indoor hobbies',
                type: 'string',
              },
            },
            outdoor: {
              type: 'array',
              items: {
                description: 'List of outdoor hobbies',
                type: 'string',
              },
            },
          },
        },
      },
    },
  },
  required: ['id'],
}

The above schema breaks the form due to this part here

outdoor: {
          type: 'array',
          title: 'Child details',
          description: 'List of outdoor hobbies',
          items: {
            description: 'List of outdoor hobbies',
            type: 'object',
            properties: {
              indoor: {
                type: 'array',
                items: {
                  description: 'List of indoor hobbies',
                  type: 'string',
                },
              },
              outdoor: {
                type: 'array',
                items: {
                  description: 'List of outdoor hobbies',
                  type: 'string',
                },
              },
            },
          },
        },

Would have loved to make a fix, but I'm encumbered

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfix in v1Is a bug in v0, but fixed in v1new featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions