jsonform / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Bootstrap 3 out of the box.
https://jsonform.github.io/jsonform/playground/index.html
MIT License
2.72k stars 553 forks source link

Expanded Fieldset + Default TabIndex set - Collapse issue (bug) #435

Closed activatedigital closed 3 months ago

activatedigital commented 10 months ago

Json: {"schema":{"friends":{"type":"array","items":{"type":"object","title":"Friend","properties":{"nick":{"type":"string","title":"Nickname"},"animals":{"type":"array","items":{"type":"string","title":"Animal name"}}}}}},"form":[{"type":"tabarray","items":{"type":"section","legend":"{{idx}}. {{value}}","items":[{"type":"fieldset","title":"About","expandable":true,"items":[{"key":"friends[].nick","valueInLegend":true}]},{"type":"fieldset","title":"Animals","expandable":true,"items":[{"type":"tabarray","items":[{"type":"section","legend":"{{idx}}. {{value}}","items":[{"key":"friends[].animals[]","valueInLegend":true}]}]}]}]}}]}

Issue:

Animated of explaination

sdetweil commented 10 months ago

ok, a little better layout with code block

{
  "schema": {
    "friends": {
      "type": "array",
      "items": {
        "type": "object",
        "title": "Friend",
        "properties": {
          "nick": {
            "type": "string",
            "title": "Nickname"
          },
          "animals": {
            "type": "array",
            "items": {
              "type": "string",
              "title": "Animal name"
            }
          }
        }
      }
    }
  },
  "form": [
    {
      "type": "tabarray",
      "items": {
        "type": "section",
        "legend": "{{idx}}. {{value}}",
        "items": [
          {
            "type": "fieldset",
            "title": "About",
            "expandable": true,
            "items": [
              {
                "key": "friends[].nick",
                "valueInLegend": true
              }
            ]
          },
          {
            "type": "fieldset",
            "title": "Animals",
            "expandable": true,
            "items": [
              {
                "type": "tabarray",
                "items": [
                  {
                    "type": "section",
                    "legend": "{{idx}}. {{value}}",
                    "items": [
                      {
                        "key": "friends[].animals[]",
                        "valueInLegend": true
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  ]
}

so you have a object with a name and an array of animals

and then you have an array of those

SO you should have a + which creates a new one of those with both fields.. a name and an array , and a new tab if we take out the form, we see this Screenshot at 2023-06-07 15-59-14

so the problem is in the form if u condense it, you don't need fieldset if there aren't multiple fields..

{
  "schema": {
    "friends": {
      "type": "array",
      "items": {
        "type": "object",
        "title": "Friend",
        "properties": {
          "nick": {
            "type": "string",
            "title": "Nickname"
          },
          "animals": {
            "type": "array",
            "items": {
              "type": "string",
              "title": "Animal name"
            }
          }
        }
      }
    }
  },
  "form": [
    {
      "type": "tabarray",
      "items": {
        "type": "section",
        "legend": "{{idx}}. {{value}}",
        "items": [
          {
                "key": "friends[].nick",
                "valueInLegend": true
          },
          {
            "type": "tabarray",
            "title": "Animals",
            "items": [
              {
                "type": "section",
                "legend": "{{idx}}. {{value}}",
                "items": [
                  {
                    "key": "friends[].animals[]",
                    "valueInLegend": true
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  ]
}

this looks like this on initial open Screenshot at 2023-06-07 16-08-07

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

sdetweil commented 4 months ago

any feedback, or can we close this issue?

sdetweil commented 3 months ago

no feedback, closing