File tree 3 files changed +26
-2
lines changed
3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change
1
+ < h2 > Basic Use Case</ h2 >
2
+
1
3
< md-sidenav-layout class ="demo-sidenav-layout ">
2
4
< md-sidenav #start (open) ="myinput.focus() " mode ="side ">
3
5
Start Side Drawer
@@ -34,4 +36,14 @@ <h1>My Content</h1>
34
36
</ div >
35
37
</ md-sidenav-layout >
36
38
37
- < h2 > Content after Sidenav</ h2 >
39
+ < h2 > Sidenav Already Opened</ h2 >
40
+
41
+ < md-sidenav-layout class ="demo-sidenav-layout ">
42
+ < md-sidenav #start2 opened mode ="side ">
43
+ Drawer
44
+ </ md-sidenav >
45
+
46
+ < div class ="demo-sidenav-content ">
47
+ < button md-button (click) ="start2.toggle() "> Toggle Start Side Drawer</ button >
48
+ </ div >
49
+ </ md-sidenav-layout >
Original file line number Diff line number Diff line change @@ -221,9 +221,12 @@ describe('MdSidenav', () => {
221
221
endSidenavTransition ( fixture ) ;
222
222
223
223
let sidenavEl = fixture . debugElement . query ( By . css ( 'md-sidenav' ) ) . nativeElement ;
224
+ let testComponent = fixture . debugElement . query ( By . css ( 'md-sidenav' ) ) . componentInstance ;
224
225
225
226
expect ( sidenavEl . classList ) . not . toContain ( 'md-sidenav-closed' ) ;
226
227
expect ( sidenavEl . classList ) . toContain ( 'md-sidenav-opened' ) ;
228
+
229
+ expect ( ( testComponent as any ) . _openPromise ) . toBeNull ( ) ;
227
230
} ) ;
228
231
229
232
it ( 'should remove align attr from DOM' , ( ) => {
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export class MdDuplicatedSidenavError extends MdError {
45
45
changeDetection : ChangeDetectionStrategy . OnPush ,
46
46
encapsulation : ViewEncapsulation . None ,
47
47
} )
48
- export class MdSidenav {
48
+ export class MdSidenav implements AfterContentInit {
49
49
/** Alignment of the sidenav (direction neutral); whether 'start' or 'end'. */
50
50
@Input ( ) align : 'start' | 'end' = 'start' ;
51
51
@@ -73,6 +73,15 @@ export class MdSidenav {
73
73
*/
74
74
constructor ( private _elementRef : ElementRef ) { }
75
75
76
+ ngAfterContentInit ( ) {
77
+ // This can happen when the sidenav is set to opened in the template and the transition
78
+ // isn't ended.
79
+ if ( this . _openPromise ) {
80
+ this . _openPromiseResolve ( ) ;
81
+ this . _openPromise = null ;
82
+ }
83
+ }
84
+
76
85
/**
77
86
* Whether the sidenav is opened. We overload this because we trigger an event when it
78
87
* starts or end.
You can’t perform that action at this time.
0 commit comments