Using new dmx-on:move event with form repeat - Is this a timing issue

Wappler 7.2.0
Windows 11
Node
MySql
local server

I have a pretty standard form repeat with draggable elements. I have exposed the hidden fields for reference.

This works as it should, allowing elements to be dragged and the index within the repeat updated. here i drag "Alert" to position 2

All good to here

I use the newly added dmx-on:moved to fire a form submit() when the element is moved and update the indexes of the elements.

so i have the following event defined:

dmx-on:moved="form_card_list.submit()"

which submits the form on move of an element
this fires as expected as seen in the developers console.

i have used a set value stage to echo out the values used for information.

    "repeat": [
        {
            "set": "Module 1 to index 0",
            "update": {
                "affected": 1
            }
        },
        {
            "set": "Module 5 to index 1",
            "update": {
                "affected": 1
            }
        },
        {
            "set": "Module 6 to index 2",
            "update": {
                "affected": 1
            }
        },
        {
            "set": "Module 7 to index 3",
            "update": {
                "affected": 1
            }
        }
    ]

Now the issue, the values sent to the SA appear to be the old values, not the updated values.
So using the above first example, we have records ordered as:

1,5,6,7

I drag record 7 to position index 1 as seen in the second screenshot, i can see record 7 now has an index of 1 as expected

HOWEVER if i examine the API action to process the changes is see:

    "repeat": [
        {
            "set": "Module 1 to index 0",
            "update": {
                "affected": 1
            }
        },
        {
            "set": "Module 5 to index 1",
            "update": {
                "affected": 1
            }
        },
        {
            "set": "Module 6 to index 2",
            "update": {
                "affected": 1
            }
        },
        {
            "set": "Module 7 to index 3",
            "update": {
                "affected": 1
            }
        }
    ]

The are still the original values.

I am guessing this is a timing issue and the dmx-on:moved is firing before the form values are refreshed?

This seems to be confirmed, adding a 50ms wait before form submit fixes the issue

1 Like

Will trigger the event with a delay in the component. It seems that the updates of its children was not finished, it did have the new position in the DOM but the name attribute was not yet updated.

Fixed in Wappler 7.3

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.