File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 88
99import { ViewContainerRef } from '@angular/core' ;
1010import { Direction } from '@angular/cdk/bidi' ;
11+ import { ScrollStrategy } from '@angular/cdk/overlay' ;
1112
1213/** Valid ARIA roles for a dialog element. */
1314export type DialogRole = 'dialog' | 'alertdialog' ;
@@ -94,5 +95,8 @@ export class MatDialogConfig<D = any> {
9495 /** Whether the dialog should focus the first focusable element on open. */
9596 autoFocus ?: boolean = true ;
9697
98+ /** Scroll strategy to be used for the dialog. */
99+ scrollStrategy ?: ScrollStrategy ;
100+
97101 // TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
98102}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import {Location} from '@angular/common';
2424import { SpyLocation } from '@angular/common/testing' ;
2525import { Directionality } from '@angular/cdk/bidi' ;
2626import { MatDialogContainer } from './dialog-container' ;
27- import { OverlayContainer } from '@angular/cdk/overlay' ;
27+ import { OverlayContainer , ScrollStrategy } from '@angular/cdk/overlay' ;
2828import { A , ESCAPE } from '@angular/cdk/keycodes' ;
2929import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
3030import {
@@ -605,6 +605,17 @@ describe('MatDialog', () => {
605605 expect ( spy ) . toHaveBeenCalled ( ) ;
606606 } ) ) ;
607607
608+ it ( 'should be able to attach a custom scroll strategy' , fakeAsync ( ( ) => {
609+ const scrollStrategy : ScrollStrategy = {
610+ attach : ( ) => { } ,
611+ enable : jasmine . createSpy ( 'scroll strategy enable spy' ) ,
612+ disable : ( ) => { }
613+ } ;
614+
615+ dialog . open ( PizzaMsg , { scrollStrategy} ) ;
616+ expect ( scrollStrategy . enable ) . toHaveBeenCalled ( ) ;
617+ } ) ) ;
618+
608619 describe ( 'passing in data' , ( ) => {
609620 it ( 'should be able to pass in data' , ( ) => {
610621 let config = {
Original file line number Diff line number Diff line change 88
99import { Directionality } from '@angular/cdk/bidi' ;
1010import {
11- BlockScrollStrategy ,
1211 Overlay ,
1312 OverlayConfig ,
1413 OverlayRef ,
@@ -49,7 +48,7 @@ export const MAT_DIALOG_SCROLL_STRATEGY =
4948
5049/** @docs -private */
5150export function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY ( overlay : Overlay ) :
52- ( ) => BlockScrollStrategy {
51+ ( ) => ScrollStrategy {
5352 return ( ) => overlay . scrollStrategies . block ( ) ;
5453}
5554
@@ -185,7 +184,7 @@ export class MatDialog {
185184 private _getOverlayConfig ( dialogConfig : MatDialogConfig ) : OverlayConfig {
186185 const state = new OverlayConfig ( {
187186 positionStrategy : this . _overlay . position ( ) . global ( ) ,
188- scrollStrategy : this . _scrollStrategy ( ) ,
187+ scrollStrategy : dialogConfig . scrollStrategy || this . _scrollStrategy ( ) ,
189188 panelClass : dialogConfig . panelClass ,
190189 hasBackdrop : dialogConfig . hasBackdrop ,
191190 direction : dialogConfig . direction ,
You can’t perform that action at this time.
0 commit comments