Hello,
I got a problem, that native ionic ItemReorder is not working while I use list of items returned from a function returning filtered array.
Here is an example of html
<ion-list reorder="true" (ionItemReorder)="reorderData($event)">
<ion-item *ngFor="let item of getItems()">
<ion-label>{{item.description}}</ion-label>
</ion-item>
</ion-list>
Where getItems() returns filtered array:
getItems(){
return this.items.filter(item => !item.archived && !item.asap);
} // Not working reorder
And function for reordering looks like this:
reorderData(indexes) {
let element = this.items[indexes.from];
this.items.splice(indexes.from, 1);
this.items.splice(indexes.to, 0, element);
}
Any idea why ItemReorder is not working? Maybe it’s a bug?
Thank you for any advice.
EDIT: Without filter it’s working. So the problem is with the filter.
getItems(){
return this.items;
} // Reorder works
EDIT2: I was debugging Reordering and the problem is, that reorder muddle indexes… It returns indexes based on array so if I have 8 items in the array, then it returns from 0 to 7. I have 2 items on my page because of filtered array. Reorder muddle indexes and thinks that first item on my page got 0 index but it actually got index 2 because It’s third item in the array.