firecmsco / firecms

Awesome Firebase/Firestore-based CMS. The missing admin panel for your Firebase project!
https://firecms.co
Other
1.13k stars 185 forks source link

Default value on array of maps properties #599

Closed nkulic closed 4 weeks ago

nkulic commented 8 months ago

What is the current behavior?

When using enumValues in a map property which is inside array (of) property, default enum value is not set.

What is the expected behavior?

Default enum value should be set.

Reproduction steps

I have created a repo with starter template and configured collection for reproduction of this issue:

Or manually create project with firecms template and modify collection config:

  1. Use starter template to create fireCMS project:
    yarn create firecms-app
    or
    npx create-firecms-app
  2. Set firebaseConfig to valid firebase project
  3. Modify collection:
    export const showcaseCollection = buildCollection({
    path: "showcase",
    customId: false,
    icon: "ShowChart",
    name: "Showcase",
    hideIdFromForm: true,
    properties: {
    featuredProducts: buildProperty({
      dataType: "array",
      name: "Featured products",
      of: {
        name: "Featured product",
        dataType: "map",
        properties: {
          size: buildProperty({
            dataType: "string",
            name: "Size",
            defaultValue: "smallVertical",
            enumValues: {
              largeVertical: { id: "largeVertical", label: "Large vertical" },
              smallVertical: { id: "smallVertical", label: "Small vertical" },
            },
          }),
          title: {
            name: "Product",
            dataType: "string",
          },
        },
      },
    }),
    },
    });

Package versions used

fgatti675 commented 4 weeks ago

This should be fixed in the latest 3.0 versions :)