Hey there,
I’m using the Reorderable List component to rearrange an array of strings and I’m wondering if there is a way to reset the list to its initial order?
For example, as my app is currently set up:
- User opens modal containing the Reorderable List component, moves the order around but decides not to submit the newly ordered list and instead closes the modal to discard changes.
- When the modal is opened again, the Reorderable List is still in the changed order rather than the order of the state variable that is passed into it.
I would like to be able to programmatically reset the order of the Reorderable List to the order of the state variable when a certain action is taken.
I have attempted to solve this by resetting the value of the state variable that is passed into the Reorderable List component to its original value using a JS script that calls the state variable’s .setValue method, which does execute successfully and can be observed by inspecting the variable on the left panel. However I have not found a way to reset the order shown in the Reorderable List, short of refreshing the entire page. I have also tried resetting the value of the state variable to an empty array before setting it back to the original array of strings but even then it appears in the changed order rather than the original.
Thanks for any help.