framework icon indicating copy to clipboard operation
framework copied to clipboard

Repeat becomes corrupted on sort

Open gp-slick-coder opened this issue 8 years ago • 5 comments
trafficstars

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

gp-slick-coder avatar Feb 20 '17 15:02 gp-slick-coder

As a reference. After running through the steps, this is the state of the array: image

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

I'm sure this has something to do with the use of sort to sort the array in place.

AshleyGrant avatar Feb 20 '17 15:02 AshleyGrant

Looks like a bug- also noticed changing the binding in the repeat to ${listService.list[$index].name} might be a workaround.

jdanyow avatar Feb 20 '17 17:02 jdanyow

i have this problem too

javadbat avatar Mar 04 '17 10:03 javadbat

${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))

gp-slick-coder avatar Apr 09 '17 08:04 gp-slick-coder

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

Alexander-Taran avatar May 24 '22 18:05 Alexander-Taran