Skip to content

Commit ec0de52

Browse files
crisbetojelbourn
authored andcommitted
fix(drag-drop): dragging class not being applied on drop container (#12921)
Fixes the `cdk-drop-dragging` class not being applied to the drop container after 5d0ec23. The introduction of the `onStable` call caused the event to be bound outside the `NgZone`.
1 parent fb7bf90 commit ec0de52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cdk/drag-drop/drag.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
218218
// their original DOM position and then they get transferred to the portal.
219219
this._ngZone.onStable.asObservable().pipe(take(1)).subscribe(() => {
220220
const rootElement = this._rootElement = this._getRootElement();
221-
rootElement.addEventListener('mousedown', this._startDragging);
222-
rootElement.addEventListener('touchstart', this._startDragging);
221+
222+
// We need to bring the events back into the `NgZone`, because of the `onStable` call.
223+
this._ngZone.run(() => {
224+
rootElement.addEventListener('mousedown', this._startDragging);
225+
rootElement.addEventListener('touchstart', this._startDragging);
226+
});
223227
});
224228
}
225229

0 commit comments

Comments
 (0)