I am trying to filter a list of items using the Drag Material CDK... all is working well when my list is not filtered, however when I filter it, and drag and drop, I get the wrong item (wrong index) on the drop, I created a working example, as you can see, filter by let's say "av" and drag avocado to drop area and you will get Carrot as the index is referring to the old data source, any ideas are appreciated,
here is a working example of the problem: https://stackblitz.com/edit/angular-agf3kv-wjxwdm?file=app/cdk-drag-drop-disabled-sorting-example.css
Sean
You should use itemsFiltered as cdkDopListData.
<div
cdkDropList
[cdkDropListData]="itemsFiltered" <-- HERE
class="example-list"
cdkDropListSortingDisabled
(cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of itemsFiltered" cdkDrag>{{item}}</div>
</div>
Stackblitz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With