|
1 | 1 | import {async, fakeAsync, tick, ComponentFixture, inject, TestBed} from '@angular/core/testing';
|
2 | 2 | import {Component, NgModule, ViewChild, ViewContainerRef} from '@angular/core';
|
| 3 | +import {dispatchFakeEvent} from '@angular/cdk/testing'; |
3 | 4 | import {
|
4 | 5 | ComponentPortal,
|
5 | 6 | PortalModule,
|
@@ -429,6 +430,40 @@ describe('Overlay', () => {
|
429 | 430 | .toBeLessThan(children.indexOf(pane), 'Expected backdrop to be before the pane in the DOM');
|
430 | 431 | });
|
431 | 432 |
|
| 433 | + it('should disable pointer events on the backdrop when scrolling', fakeAsync(() => { |
| 434 | + let overlayRef = overlay.create(config); |
| 435 | + overlayRef.attach(componentPortal); |
| 436 | + |
| 437 | + viewContainerFixture.detectChanges(); |
| 438 | + let backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement; |
| 439 | + |
| 440 | + expect(backdrop.style.pointerEvents).toBeFalsy(); |
| 441 | + |
| 442 | + dispatchFakeEvent(backdrop, 'wheel'); |
| 443 | + |
| 444 | + expect(backdrop.style.pointerEvents).toBe('none'); |
| 445 | + |
| 446 | + tick(100); |
| 447 | + |
| 448 | + expect(backdrop.style.pointerEvents).toBeFalsy(); |
| 449 | + })); |
| 450 | + |
| 451 | + it('should not disable pointer events on the backdrop when scrolling is blocked', () => { |
| 452 | + config.scrollStrategy = overlay.scrollStrategies.block(); |
| 453 | + |
| 454 | + let overlayRef = overlay.create(config); |
| 455 | + overlayRef.attach(componentPortal); |
| 456 | + |
| 457 | + viewContainerFixture.detectChanges(); |
| 458 | + let backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement; |
| 459 | + |
| 460 | + expect(backdrop.style.pointerEvents).toBeFalsy(); |
| 461 | + |
| 462 | + dispatchFakeEvent(backdrop, 'wheel'); |
| 463 | + |
| 464 | + expect(backdrop.style.pointerEvents).toBeFalsy(); |
| 465 | + }); |
| 466 | + |
432 | 467 | });
|
433 | 468 |
|
434 | 469 | describe('panelClass', () => {
|
|
0 commit comments