Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking interaction between dynamic lists and tables #1064

Closed
Skaiir opened this issue Feb 21, 2024 · 4 comments · Fixed by #1088
Closed

Breaking interaction between dynamic lists and tables #1064

Skaiir opened this issue Feb 21, 2024 · 4 comments · Fixed by #1088
Assignees
Labels
bug Something isn't working

Comments

@Skaiir
Copy link
Contributor

Skaiir commented Feb 21, 2024

Describe the Bug

This form apparently breaks form-js

{
  "components": [
    {
      "label": "Table",
      "type": "table",
      "layout": {
        "row": "Row_191hb77",
        "columns": null
      },
      "dataSource": "=Field_0r3jms4",
      "rowCount": 3,
      "id": "Field_0r3jms4",
      "columns": [
        {
          "label": "ID",
          "key": "id"
        },
        {
          "label": "Name",
          "key": "name"
        },
        {
          "label": "Date",
          "key": "date"
        }
      ]
    },
    {
      "label": "Number",
      "type": "number",
      "layout": {
        "row": "Row_0dbmu1z",
        "columns": null
      },
      "id": "Field_0fsxs1b",
      "key": "idfilter",
      "defaultValue": 2
    },
    {
      "components": [
        {
          "components": [
            {
              "text": "{{this.id}}",
              "label": "Text view",
              "type": "text",
              "layout": {
                "row": "Row_06z1kim",
                "columns": null
              },
              "id": "Field_0kypubr"
            },
            {
              "label": "Number",
              "type": "number",
              "layout": {
                "row": "Row_0dx6ob8",
                "columns": null
              },
              "id": "Field_0kzopb8",
              "key": "id"
            },
            {
              "label": "Text field",
              "type": "textfield",
              "layout": {
                "row": "Row_1el0dpw",
                "columns": null
              },
              "id": "Field_1jpezr9",
              "key": "name"
            },
            {
              "label": "Text field",
              "type": "textfield",
              "layout": {
                "row": "Row_0sr7lrz",
                "columns": null
              },
              "id": "Field_0ahpidx",
              "key": "date"
            }
          ],
          "showOutline": true,
          "label": "Group",
          "type": "group",
          "layout": {
            "row": "Row_1dr2rq5",
            "columns": null
          },
          "id": "Field_1s20g9l",
          "conditional": {
            "hide": "=this.id < idfilter"
          }
        },
        {
          "label": "Separator",
          "type": "separator",
          "layout": {
            "row": "Row_1q2u5mi",
            "columns": null
          },
          "id": "Field_1uzwox6"
        }
      ],
      "showOutline": true,
      "isRepeating": true,
      "allowAddRemove": true,
      "defaultRepetitions": 1,
      "label": "Dynamic list",
      "type": "dynamiclist",
      "layout": {
        "row": "Row_1w1xmo6",
        "columns": null
      },
      "id": "Field_0596cy3",
      "path": "Field_0r3jms4",
      "nonCollapsedItems": null
    }
  ],
  "type": "default",
  "id": "Form_1je5j4d",
  "executionPlatform": "Camunda Cloud",
  "executionPlatformVersion": "8.4.0",
  "exporter": {
    "name": "Camunda Modeler",
    "version": "5.20.0"
  },
  "schemaVersion": 15
}

Steps to Reproduce

  • Load the following form into the playground

Expected Behavior

  • Form should load without error
@Skaiir Skaiir added bug Something isn't working ready Ready to be worked on labels Feb 21, 2024
@Skaiir Skaiir self-assigned this Feb 21, 2024
@Skaiir
Copy link
Contributor Author

Skaiir commented Feb 22, 2024

The issue as far as I understand it:

There is some faulty interaction somewhere between the table's data initialization and the dynamic list leading to an element of the array to be dropped (element 0 becomes empty). This messes with the chunking logic for the table as we use reduce, which ends up starting at index 1, leading to an error.

Soft fix would be to filter the array of empty elements in the chunking logic.
Still have to figure out where and why that initial element is getting wiped, but that would be the true fix, not having the element become empty.

@Skaiir Skaiir changed the title Breaking form (to outline) Breaking form Mar 5, 2024
@Skaiir
Copy link
Contributor Author

Skaiir commented Mar 6, 2024

More investigations: there is something very strange going on with the data context where the id is somehow an array in this scenario.

grafik

@Skaiir Skaiir added in progress Currently worked on and removed ready Ready to be worked on labels Mar 6, 2024
@Skaiir
Copy link
Contributor Author

Skaiir commented Mar 6, 2024

May be related to #1085

Actually a separate issue. Although the above issue was interfering with the fixing of this one.

RCA

Conditional hiding logic on dynamic list group causes deletion of the array element in the working state, the thing is the way the array element is deleted is not via removing the element from the array, but rather by setting it to an empty element, so we end up with arrays of the form [ <empty>, element 2, element 3 ].

The chunking logic of the table makes use of reduce, as previously mentioned, but because the empty element is present, the indexes used in reduce are offset, which breaks the reduction logic.

So I'm not sure what the fix here is, the way I see it either we make sure that we don't create these empty elements, but I believe this will cause issues with the rendering of the dynamic list. Another option that may keep the hierarchy intact would be to create null values, but then we will need to filter those out on submit. The simplest fix would be to filter out empty elements from the table data source. I'll try this out.

Skaiir added a commit that referenced this issue Mar 7, 2024
@Skaiir Skaiir changed the title Breaking form Breaking interaction between dynamic lists and tables Mar 7, 2024
Skaiir added a commit that referenced this issue Mar 20, 2024
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Mar 20, 2024
Skaiir added a commit that referenced this issue Mar 25, 2024
Skaiir added a commit that referenced this issue Mar 25, 2024
Skaiir added a commit that referenced this issue Mar 25, 2024
@Skaiir
Copy link
Contributor Author

Skaiir commented Mar 25, 2024

Fixed via #1088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant