json-editor icon indicating copy to clipboard operation
json-editor copied to clipboard

Tabbed array editor doesn't show item properties on IE11 when minItems > 0

Open mazswojejzony opened this issue 12 years ago • 6 comments

Works fine on Chrome but unfortunately fails on IE11.

To reproduce please go to the http://jeremydorn.com/json-editor/ and paste the following schema:

{
    "type": "object",
    "properties": 
    {
        "some_property": 
        {
            "type": "string"
        },
        "some_array":
        {
            "type": "array",
            "format": "tabs",
            "title": "Array Items",
            "minItems": 1,
            "items": 
            {
                "type": "object",
                "properties": 
                {
                    "name": 
                    {
                        "type": "string"
                    },

                    "age": 
                    {
                        "type": "integer"
                    }
                }
            }
        }
    }
}

Then you will notice that under Items 1 there are no name and age fields. When you click + item button you will see those properties are visible on the item 2 tab but still not visible on item 1 tab.

This issue is related to the minItems option: the number of broken tabs is equivalent to the value of minItems option.

mazswojejzony avatar Sep 04 '14 09:09 mazswojejzony

Looks like there is a work-around - adding "required": ["name", "age"] in the schema. But this is just a work-around...

EDIT 1: ~~This work-around does not work for more complex schemas when one of properties is an object.~~

EDIT 2: Actually the work-around also works for complex schemas. minItems = 0 solves the problem too but obviously changes schema validation logic.

Anyway, it would be great to fix this in code.

mazswojejzony avatar Sep 04 '14 09:09 mazswojejzony

I think this is actually the expected behavior of minItems on an array. I'm seeing this same thing in both IE11 and Chrome. Seems like json-editor only renders the required properties of array items when minItems is set on an array in the schema, but I don't know if it is intentional or not.

If you set the disable_properties option on your editor instance to false, you can expose the Properties button to enable adding of all the other non-required properties of each array item for your minItems=1 arrays. Seems like a workaround that shouldn't be necessary, so it would be ideal if you could customize this behavior somehow.

paulcullin avatar Sep 11 '14 22:09 paulcullin

I do not agree this is the expected behavior - when minItems is missing in the schema or it is equal to zero then editor works as expected: you can add new item and set all properties as you wish. Why setting minItems to 1 should change the behavior in this regard?

On 12 September 2014 00:14, Paul Cullin [email protected] wrote:

I think this is actually the expected behavior of minItems on an array. I'm seeing this same thing in both IE11 and Chrome. Seems like json-editor only renders the required properties of array items when minItems is set on an array in the schema, but I don't know if it is intentional or not.

If you set the disable_properties option on your editor instance to false, you can expose the Properties button to enable adding of all the other non-required properties of each array item for your minItems=1 arrays. Seems like a workaround that shouldn't be necessary, so it would be ideal if you could customize this behavior somehow.

— Reply to this email directly or view it on GitHub https://github.com/jdorn/json-editor/issues/246#issuecomment-55336944.

mazswojejzony avatar Sep 14 '14 15:09 mazswojejzony

@mazswojejzony please refer to Issue #220 for further discussion on this topic. @jdorn describes the reasoning behind this functionality there, and it would be a good place for you to voice your opinion about changing it (as I and the issue creator have done).

paulcullin avatar Sep 15 '14 19:09 paulcullin

Should be fixed now. Let me know if you still notice problems.

jdorn avatar Sep 15 '14 23:09 jdorn

Works as expected. Thanks a lot!

mazswojejzony avatar Sep 16 '14 08:09 mazswojejzony