Tabbed array editor doesn't show item properties on IE11 when minItems > 0
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.
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.
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.
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 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).
Should be fixed now. Let me know if you still notice problems.
Works as expected. Thanks a lot!