formio / angular-material

JSON powered forms for Angular Material
https://form.io
MIT License
45 stars 39 forks source link

[BUG] Extra empty item at select component #140

Open weihan1394 opened 4 years ago

weihan1394 commented 4 years ago

I have recently upgraded the formio to the latest version and I realized this weird behavior at select component. There will always be an empty item above all the specified items as populated from the json. I have attached the behavior for referencing.

Environment

Steps to Reproduce

  1. Update the json file as below
  2. When the form is generated, the select component will have an empty item above.

Expected behavior

No empty item above

Observed behavior

Extra empty item above

Example

Json

{
    "components": [
        {
            "type": "select",
            "label": "Single Select",
            "key": "single",
            "placeholder": "Select one",
            "data": {
                "values": [
                    {
                        "value": "apple",
                        "label": "Apple"
                    },
                    {
                        "value": "banana",
                        "label": "Banana"
                    },
                    {
                        "value": "pear",
                        "label": "Pear"
                    },
                    {
                        "value": "orange",
                        "label": "Orange"
                    }
                ]
            },
            "dataSrc": "values",
            "defaultValue": "banana",
            "template": "<span>{{ item.label }}</span>"
        }
    ]
}
screenshot
Asifislam110 commented 4 years ago

I faced the same need. Could anyone help with implementation? Any advice is welcome

albert5287 commented 4 years ago

I have created a PR to solve this issue https://github.com/formio/angular-material-formio/pull/144

haschu commented 4 years ago

Hey, just a friendly reminder that a PR with a quick-fix was submitted by @albert5287. Should be fairly easy to merge, as it doesn't break anything :slightly_smiling_face: