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

When using a filtered ng-repeat the DOM element index differs from model index #98

Open
debslord opened this issue Nov 8, 2016 · 2 comments

Comments

@debslord
Copy link

debslord commented Nov 8, 2016

Currently you cannot drag items while the list is filtered. dragula becomes confused with the array index.
In this plunker example you can try to search for "t" and then drag and drop "them" within the list. You will notice, that the hidden "Explore" will be moved instead.

http://plnkr.co/edit/bKNeo9cyKyjY3GpJcIhY?p=preview

Plnkr taken from here: #29
Also highlighted that would be issue with this pull request: #9

@ageiser26
Copy link

@debslord
I'm not sure if it'll help you or not but, my team had the same problem today.

I edited service.js line #50 to include the following -

if (dropElm.hasAttribute('ng-repeat')) { dropElmModel = angular.element(dropElm).scope()[dropElm.getAttribute('ng-repeat').split(' ')[0]]; dragIndex = sourceModel.indexOf(dropElmModel); }

This finds the index of the model in unfiltered source. It's barbaric and but, it gets the job done.

@joster-dev
Copy link

+1
not using filter exactly but it does not work when using pipes that alter the positioning of items on screen

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

No branches or pull requests

3 participants