mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Jeremy Elbourn
parent
fb7bf900c0
commit
ec0de52b68
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user