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 8
8
9
9
import { ViewContainerRef } from '@angular/core' ;
10
10
import { Direction } from '@angular/cdk/bidi' ;
11
+ import { ScrollStrategy } from '@angular/cdk/overlay' ;
11
12
12
13
/** Valid ARIA roles for a dialog element. */
13
14
export type DialogRole = 'dialog' | 'alertdialog' ;
@@ -94,5 +95,8 @@ export class MatDialogConfig<D = any> {
94
95
/** Whether the dialog should focus the first focusable element on open. */
95
96
autoFocus ?: boolean = true ;
96
97
98
+ /** Scroll strategy to be used for the dialog. */
99
+ scrollStrategy ?: ScrollStrategy ;
100
+
97
101
// TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
98
102
}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import {Location} from '@angular/common';
24
24
import { SpyLocation } from '@angular/common/testing' ;
25
25
import { Directionality } from '@angular/cdk/bidi' ;
26
26
import { MatDialogContainer } from './dialog-container' ;
27
- import { OverlayContainer } from '@angular/cdk/overlay' ;
27
+ import { OverlayContainer , ScrollStrategy } from '@angular/cdk/overlay' ;
28
28
import { A , ESCAPE } from '@angular/cdk/keycodes' ;
29
29
import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
30
30
import {
@@ -605,6 +605,17 @@ describe('MatDialog', () => {
605
605
expect ( spy ) . toHaveBeenCalled ( ) ;
606
606
} ) ) ;
607
607
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
+
608
619
describe ( 'passing in data' , ( ) => {
609
620
it ( 'should be able to pass in data' , ( ) => {
610
621
let config = {
Original file line number Diff line number Diff line change 8
8
9
9
import { Directionality } from '@angular/cdk/bidi' ;
10
10
import {
11
- BlockScrollStrategy ,
12
11
Overlay ,
13
12
OverlayConfig ,
14
13
OverlayRef ,
@@ -49,7 +48,7 @@ export const MAT_DIALOG_SCROLL_STRATEGY =
49
48
50
49
/** @docs -private */
51
50
export function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY ( overlay : Overlay ) :
52
- ( ) => BlockScrollStrategy {
51
+ ( ) => ScrollStrategy {
53
52
return ( ) => overlay . scrollStrategies . block ( ) ;
54
53
}
55
54
@@ -185,7 +184,7 @@ export class MatDialog {
185
184
private _getOverlayConfig ( dialogConfig : MatDialogConfig ) : OverlayConfig {
186
185
const state = new OverlayConfig ( {
187
186
positionStrategy : this . _overlay . position ( ) . global ( ) ,
188
- scrollStrategy : this . _scrollStrategy ( ) ,
187
+ scrollStrategy : dialogConfig . scrollStrategy || this . _scrollStrategy ( ) ,
189
188
panelClass : dialogConfig . panelClass ,
190
189
hasBackdrop : dialogConfig . hasBackdrop ,
191
190
direction : dialogConfig . direction ,
You can’t perform that action at this time.
0 commit comments