Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

using track by in ng-repeat will cause dnd-moved not to trigger #500

Open
Mr-Skribbls opened this issue Oct 19, 2018 · 3 comments
Open

using track by in ng-repeat will cause dnd-moved not to trigger #500

Mr-Skribbls opened this issue Oct 19, 2018 · 3 comments

Comments

@Mr-Skribbls
Copy link

Mr-Skribbls commented Oct 19, 2018

I made the mistake of using track by $index in ng-repeat. Like this:
<script type="text/ng-template" id="list.html">
<ul dnd-list="list">
<li ng-repeat="item in list track by $index"
dnd-draggable="item"
dnd-effect-allowed="move"
dnd-moved="list.splice($index, 1)"
dnd-selected="models.selected = item"
ng-class="{selected: models.selected === item}"
ng-include="item.type + '.html'">
</li>
</ul>
</script>
this causes dnd-moved to not trigger when you drag a bottom item up the list. Causing there to be duplicates.
I reproduced this using the demo code.

@warlockdn
Copy link

Were you able to solve this ?

@Mr-Skribbls
Copy link
Author

no I had to remove the track by for it to work

@lorenzo-dd
Copy link

lorenzo-dd commented Jun 12, 2019

I confirm that track by $index breaks the whole thing!!!
It actually drags the item but the $index passed to the dragMoved callback is sometimes wrong, making you delete the wrong item and actually duplicating the one you just moved.

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

No branches or pull requests

3 participants