Skip to content

Commit 3479123

Browse files
committed
fix(cdk/drag-drop): ensure container is registered in addItem (#31518)
Currently we only sync drop container in the `CdkDrag` container. These changes move the logic into `addItem` to ensure that it always happens. Fixes #31514. (cherry picked from commit a384870)
1 parent d432818 commit 3479123

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
248248
// is too late since the two modes save different kinds of information. We work around it by
249249
// assigning the drop container both from here and the list.
250250
if (dropContainer) {
251-
this._dragRef._withDropContainer(dropContainer._dropListRef);
252251
dropContainer.addItem(this);
253252

254253
// The drop container reads this so we need to sync it here.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export class CdkDropList<T = any> implements OnDestroy {
235235
/** Registers an items with the drop list. */
236236
addItem(item: CdkDrag): void {
237237
this._unsortedItems.add(item);
238+
item._dragRef._withDropContainer(this._dropListRef);
238239

239240
// Only sync the items while dragging since this method is
240241
// called when items are being initialized one-by-one.

0 commit comments

Comments
 (0)