diff --git a/src/cdk/drag-drop/directives/drag.spec.ts b/src/cdk/drag-drop/directives/drag.spec.ts
index 0f7504b58303..ae401cc1d859 100644
--- a/src/cdk/drag-drop/directives/drag.spec.ts
+++ b/src/cdk/drag-drop/directives/drag.spec.ts
@@ -461,6 +461,25 @@ describe('CdkDrag', () => {
expect(element.classList).not.toContain('cdk-drag-dragging');
}));
+ it('should add a class while an element is being dragged with OnPush change detection',
+ fakeAsync(() => {
+ const fixture = createComponent(StandaloneDraggableWithOnPush);
+ fixture.detectChanges();
+
+ const element = fixture.componentInstance.dragElement.nativeElement;
+
+ expect(element.classList).not.toContain('cdk-drag-dragging');
+
+ startDraggingViaMouse(fixture, element);
+
+ expect(element.classList).toContain('cdk-drag-dragging');
+
+ dispatchMouseEvent(document, 'mouseup');
+ fixture.detectChanges();
+
+ expect(element.classList).not.toContain('cdk-drag-dragging');
+ }));
+
it('should not add a class if item was not dragged more than the threshold', fakeAsync(() => {
const fixture = createComponent(StandaloneDraggable, [], 5);
fixture.detectChanges();
@@ -2821,6 +2840,17 @@ class StandaloneDraggable {
boundarySelector: string;
}
+@Component({
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ template: `
+
+ `
+})
+class StandaloneDraggableWithOnPush {
+ @ViewChild('dragElement') dragElement: ElementRef;
+ @ViewChild(CdkDrag) dragInstance: CdkDrag;
+}
+
@Component({
template: `