framework
framework copied to clipboard
Repeat becomes corrupted on sort
Hi guys,
the repeater does not reflect the items order with the underlying array. See the Gist demo to reproduce the issue.
https://gist.run/?id=ba12e33c7589c7b21386791286b3c37b
Thanks, George
-
Library Version: 1.0.8
-
Operating System: Windows [10]
-
Node Version: 6.9.4
-
Browser: FF | Chrome
As a reference. After running through the steps, this is the state of the array:

And below is the display I'm getting for the array:

I'm sure this has something to do with the use of sort to sort the array in place.
Looks like a bug- also noticed changing the binding in the repeat to ${listService.list[$index].name} might be a workaround.
i have this problem too
${listService.list[$index].name} do not really solve the problem. Modifying the array (e.g. deleting an item) after executing the sort method results again in binding issues.
The only workaround that is acceptable so far is to do a new instance of the array
group.items = new Array(...group.items.sort(YOUR_SORTING))
Sort mutates the array We either have to override it in framework as we do for splice, push etc.. or one has to assign new array to the observed variable
@bigopon can close this