@@ -10,14 +10,23 @@ import {Direction, Directionality} from '@angular/cdk/bidi';
10
10
import { ComponentPortal , Portal , PortalOutlet , TemplatePortal } from '@angular/cdk/portal' ;
11
11
import { ComponentRef , EmbeddedViewRef , NgZone } from '@angular/core' ;
12
12
import { Location } from '@angular/common' ;
13
- import { Observable , Subject , merge , SubscriptionLike , Subscription , Observer } from 'rxjs' ;
14
- import { take , takeUntil } from 'rxjs/operators' ;
13
+ import {
14
+ Observable ,
15
+ Subject ,
16
+ merge ,
17
+ SubscriptionLike ,
18
+ Subscription ,
19
+ Observer ,
20
+ fromEvent ,
21
+ } from 'rxjs' ;
22
+ import { take , takeUntil , tap , debounceTime } from 'rxjs/operators' ;
15
23
import { OverlayKeyboardDispatcher } from './keyboard/overlay-keyboard-dispatcher' ;
16
24
import { OverlayConfig } from './overlay-config' ;
17
25
import { coerceCssPixelValue , coerceArray } from '@angular/cdk/coercion' ;
18
26
import { OverlayReference } from './overlay-reference' ;
19
27
import { PositionStrategy } from './position/position-strategy' ;
20
28
import { ScrollStrategy } from './scroll' ;
29
+ import { BlockScrollStrategy } from './scroll/block-scroll-strategy' ;
21
30
22
31
23
32
/** An object where all of its properties cannot be written. */
@@ -393,6 +402,19 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
393
402
this . _backdropElement . addEventListener ( 'click' ,
394
403
( event : MouseEvent ) => this . _backdropClick . next ( event ) ) ;
395
404
405
+ if ( ! ( this . _config . scrollStrategy instanceof BlockScrollStrategy ) ) {
406
+ // When the user starts scrolling by mouse, disable pointer events on the backdrop. This
407
+ // allows for non-body scroll containers (e.g. a sidenav container), which would normally
408
+ // be blocked due to the backdrop, to scroll. When the user has stopped scrolling for 100ms
409
+ // restore the pointer events in order for the click handler to work.
410
+ this . _ngZone . runOutsideAngular ( ( ) => {
411
+ fromEvent ( this . _backdropElement ! , 'wheel' ) . pipe (
412
+ tap ( ( ) => this . _backdropElement ! . style . pointerEvents = 'none' ) ,
413
+ debounceTime ( 100 )
414
+ ) . subscribe ( ( ) => this . _backdropElement ! . style . pointerEvents = '' ) ;
415
+ } ) ;
416
+ }
417
+
396
418
// Add class to fade-in the backdrop after one frame.
397
419
if ( typeof requestAnimationFrame !== 'undefined' ) {
398
420
this . _ngZone . runOutsideAngular ( ( ) => {
0 commit comments