You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x
Current Behavior
I've got an array of arrays stored in state called items, I want to reorder the array of arrays and save it within state with the new order. Instead I seem to get a random order.
Expected Behavior
I expect it to work so that when I reorder the array of arrays, the order stays in that new order and I'm able to save it in state. The order stays how I expect it to only if I get rid of the line where I try to use setItems to save the new order.
Thanks for the issue. I am going to close this as this is not a bug in Ionic Framework. As per the Reorder Updating Data documentation, Ionic will try to reorder the DOM nodes when calling event.detail.complete. This clashes with React's render lifecycle which is why the position appears to be reset. In this case, you should pass false to event.detail.complete to prevent Ionic from reordering the DOM nodes.
Alternatively, you could simplify this code even more by calling setItems(event.detail.complete(items)); which will have Ionic handle reordering the array for you. Passing in the items array will also disable Ionic's automatic DOM reorder behavior.
One other option I forgot to mention is you can use key to assign a stable identity to each element in your loop. Something like this should work too (and let you keep your existing doReorder implementation):
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Prerequisites
Ionic Framework Version
v7.x
Current Behavior
I've got an array of arrays stored in state called
items,
I want to reorder the array of arrays and save it within state with the new order. Instead I seem to get a random order.Expected Behavior
I expect it to work so that when I reorder the array of arrays, the order stays in that new order and I'm able to save it in state. The order stays how I expect it to only if I get rid of the line where I try to use
setItems
to save the new order.Steps to Reproduce
https://stackblitz.com/edit/ionic-react-starter-telztw?file=pages%2FHome.js
Try and reorder the list here. I can't get it to stick.
Code Reproduction URL
https://stackblitz.com/edit/ionic-react-starter-telztw?file=pages%2FHome.js
Ionic Info
Ionic:
Ionic CLI : 7.1.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 7.2.3
Capacitor:
Capacitor CLI : 5.2.3
@capacitor/android : 5.2.3
@capacitor/core : 5.2.3
@capacitor/ios : 5.3.0
Utility:
cordova-res : 0.15.4
native-run (update available: 2.0.0) : 1.7.2
System:
NodeJS : v16.20.0 (/usr/local/bin/node)
npm : 8.19.4
OS : Linux 5.14
Additional Information
No response
The text was updated successfully, but these errors were encountered: