guillotinaweb / ngx-schema-form

HTML form generation based on JSON Schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

visibilityIf no longer works when target is multiple Select widget

aharaguchi opened this issue · comments

commented

We recently upgraded to 2.8.4 and noticed that our form schemas' conditionals are no longer working.
2.8.1 seems alright whereas 2.8.2 isn't, so I believe this is the PR that broke it.

Expected Behaviour:
When selecting multiple options from the Select widget, each option selected should cause corresponding numerical fields to appear.

Current Behaviour:
The numerical field for only the first option selected appears.

I noticed that in 2.8.1's __evaluateVisibilityIf function, the value param would come in as "Option #1", "Option #2", etc.
in 2.8.4, only "Option #1" is ever passed into the function.

Form Schema:

    "properties": {
        "select1-8ab066ff9843": {
            "type": "array",
            "title": "Select",
            "widget": "select",
            "items": {
                "type": "string",
                "oneOf": [
                    {
                        "name": "Option #1",
                        "value": "Option #1",
                        "enum": [
                            "Option #1"
                        ]
                    },
                    {
                        "name": "Option #2",
                        "value": "Option #2",
                        "enum": [
                            "Option #2"
                        ]
                    },
                    {
                        "name": "Option #3",
                        "value": "Option #3",
                        "enum": [
                            "Option #3"
                        ]
                    }
                ]
            },
            "minItems": 1
        },
        "number1-6dc3da6da315": {
            "type": "number",
            "title": "1",
            "widget": "number",
            "visibleIf": {
                "oneOf": [
                    {
                        "/select1-8ab066ff9843/*": [
                            "Option #1"
                        ]
                    }
                ]
            }
        },
        "number2-00405c0b6224": {
            "type": "number",
            "title": "2",
            "widget": "number",
            "visibleIf": {
                "oneOf": [
                    {
                        "/select1-8ab066ff9843/*": [
                            "Option #2"
                        ]
                    }
                ]
            }
        },
        "number3-e38258301694": {
            "type": "number",
            "title": "3",
            "widget": "number",
            "visibleIf": {
                "oneOf": [
                    {
                        "/select1-8ab066ff9843/*": [
                            "Option #3"
                        ]
                    }
                ]
            }
        }
    }
}```

Yeah, sorry. I introduced this bug by the feature. I already fixed it 17 days ago but it is not merged so far. See #452

commented

Ooo thank you so much @KBroichhausen , this is awesome! I saw your PR but wasn't able to find the time to look into exactly what was going wrong with the issue. Appreciate it.