|
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,
|
@@ -409,6 +410,40 @@ describe('Overlay', () => {
|
409 | 410 | .toBeLessThan(children.indexOf(pane), 'Expected backdrop to be before the pane in the DOM');
|
410 | 411 | });
|
411 | 412 |
|
| 413 | + it('should disable pointer events on the backdrop when scrolling', fakeAsync(() => { |
| 414 | + let overlayRef = overlay.create(config); |
| 415 | + overlayRef.attach(componentPortal); |
| 416 | + |
| 417 | + viewContainerFixture.detectChanges(); |
| 418 | + let backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement; |
| 419 | + |
| 420 | + expect(backdrop.style.pointerEvents).toBeFalsy(); |
| 421 | + |
| 422 | + dispatchFakeEvent(backdrop, 'wheel'); |
| 423 | + |
| 424 | + expect(backdrop.style.pointerEvents).toBe('none'); |
| 425 | + |
| 426 | + tick(100); |
| 427 | + |
| 428 | + expect(backdrop.style.pointerEvents).toBeFalsy(); |
| 429 | + })); |
| 430 | + |
| 431 | + it('should not disable pointer events on the backdrop when scrolling is blocked', () => { |
| 432 | + config.scrollStrategy = overlay.scrollStrategies.block(); |
| 433 | + |
| 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).toBeFalsy(); |
| 445 | + }); |
| 446 | + |
412 | 447 | });
|
413 | 448 |
|
414 | 449 | describe('panelClass', () => {
|
|
0 commit comments