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 5d0ec23b1d. The introduction of the `onStable` call caused the event to be bound outside the `NgZone`.
This commit is contained in:
Kristiyan Kostadinov
2018-09-11 19:39:42 +02:00
committed by Jeremy Elbourn
parent fb7bf900c0
commit ec0de52b68
+6 -2
View File
@@ -218,8 +218,12 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
// their original DOM position and then they get transferred to the portal.
this._ngZone.onStable.asObservable().pipe(take(1)).subscribe(() => {
const rootElement = this._rootElement = this._getRootElement();
rootElement.addEventListener('mousedown', this._startDragging);
rootElement.addEventListener('touchstart', this._startDragging);
// We need to bring the events back into the `NgZone`, because of the `onStable` call.
this._ngZone.run(() => {
rootElement.addEventListener('mousedown', this._startDragging);
rootElement.addEventListener('touchstart', this._startDragging);
});
});
}