Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
cdkDrag does nothing when inside an *ngFor looping through a returned 2 dimensional array #15807
What is the expected behavior?
cdkDrag works from inside an ngFor looping through an array with a nested array.
What is the current behavior?
Nothing happens. cdkDrag does not move or drag.
What are the steps to reproduce?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
chrome browser, angular 7.1.0 and 7.2.0, material 7.1.0 and 7.3.7
Is there anything else we should know?
Happy to explain more if this isn't clear. Had me stumped for hours. :(
This is because calling
Because of that, the draggable item is recreated on every CD cycle, which resets its position. This can be proven easily by making the component OnPush making the items draggable.
So this is actually not a bug, but just incorrect usage. Generally you just shouldn't call functions from templates, but if you must, specifying a