Skip to content

Commit 52aa210

Browse files
authored
fix(cdk/drag-drop): destroyed items not being cleaned up correctly (#21821)
Fixes a memory leak in `CdkDrag` which prevented it from being cleaned up. The problem is that we keep track of all the instances in an array, but there was a typo in the cleanup logic which meant that the items would never be removed from the array. Fixes #21818.
1 parent 831cbbf commit 52aa210

File tree

1 file changed

+1
-1
lines changed
  • src/cdk/drag-drop/directives

1 file changed

+1
-1
lines changed

src/cdk/drag-drop/directives/drag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
327327

328328
const index = CdkDrag._dragInstances.indexOf(this);
329329
if (index > -1) {
330-
CdkDrag._dragInstances.splice(index, -1);
330+
CdkDrag._dragInstances.splice(index, 1);
331331
}
332332
this._destroyed.next();
333333
this._destroyed.complete();

0 commit comments

Comments
 (0)