jsoneditor icon indicating copy to clipboard operation
jsoneditor copied to clipboard

JSON Editor doesn't create Dropdowns for Arrays

Open KIKOmanasijev opened this issue 3 years ago • 3 comments

JSON Editor won't create Dropdowns for Object Property, if the objects are in an array.

image

So I've been using JSON Schema enum's to make the app's stakeholders life easier (and validate the input), but I've noticed a weird bug when using array of objects. Basically, a Popover dialog will be shown for the property that says "should be equal to A, B, or C", but dropdown won't be displayed.

image

I've tried using enum on a object property (object not in an array), and Dropdowns are being rendered as defined.

KIKOmanasijev avatar Oct 04 '22 15:10 KIKOmanasijev

Came here looking for a solution for the same problem.

Probably same issue reported over here: https://github.com/josdejong/jsoneditor/issues/1404

trajche avatar Oct 04 '22 17:10 trajche

To confirm and further explain my problem, here is a little demonstration:

Array of Objects, dropdown selector don't appear for 'material' dropdown even though I have enum defined. Only showing "should be one of..." https://jsoneditoronline.org/#right=cloud.cb1dfeb53a204e65a2f9993854ad9a37&left=cloud.a82449cff4304e0f8b8e496d3fba433e

Just a single object with materials property, same structure but enum dropdown is being rendered when entering the 'material' values. https://jsoneditoronline.org/#right=cloud.cb1dfeb53a204e65a2f9993854ad9a37&left=cloud.a82449cff4304e0f8b8e496d3fba433e

KIKOmanasijev avatar Oct 04 '22 19:10 KIKOmanasijev

Thanks for reporting. I'll paste the code example from @KIKOmanasijev here so we will not lose it in the future:

Schema:

{
  "type": "object",
  "properties": {
    "colors": {
      "type": "array",
      "items": [
        {
          "type": "object",
          "properties": {
            "material": {
              "type": "string",
              "enum": [ "green", "yellow", "red" ]
            }
          }
        }
      ]
    }
  }
}

Document:

{
  "colors": [
    {
      "material": "dark"
    }
  ]
}

Help debugging this would be welcome. Anyone?

josdejong avatar Oct 05 '22 07:10 josdejong