Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeat becomes corrupted on sort #721

Open
gp-slick-coder opened this issue Feb 20, 2017 · 5 comments
Open

Repeat becomes corrupted on sort #721

gp-slick-coder opened this issue Feb 20, 2017 · 5 comments
Assignees
Labels

Comments

@gp-slick-coder
Copy link

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

@AshleyGrant
Copy link
Collaborator

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.

@jdanyow jdanyow added the bug label Feb 20, 2017
@jdanyow
Copy link
Contributor

jdanyow commented Feb 20, 2017

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

@jdanyow jdanyow changed the title Repeater Binding Error (on sorting the array) Repeat becomes corrupted on sort Feb 20, 2017
@javadbat
Copy link

javadbat commented Mar 4, 2017

i have this problem too

@gp-slick-coder
Copy link
Author

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

@Alexander-Taran
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants