File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1+ < h2 > Basic Use Case</ h2 >
2+
13< md-sidenav-layout class ="demo-sidenav-layout ">
24 < md-sidenav #start (open) ="myinput.focus() " mode ="side ">
35 Start Side Drawer
@@ -34,4 +36,14 @@ <h1>My Content</h1>
3436 </ div >
3537</ md-sidenav-layout >
3638
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', () => {
221221 endSidenavTransition ( fixture ) ;
222222
223223 let sidenavEl = fixture . debugElement . query ( By . css ( 'md-sidenav' ) ) . nativeElement ;
224+ let testComponent = fixture . debugElement . query ( By . css ( 'md-sidenav' ) ) . componentInstance ;
224225
225226 expect ( sidenavEl . classList ) . not . toContain ( 'md-sidenav-closed' ) ;
226227 expect ( sidenavEl . classList ) . toContain ( 'md-sidenav-opened' ) ;
228+
229+ expect ( ( testComponent as any ) . _openPromise ) . toBeNull ( ) ;
227230 } ) ;
228231
229232 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 {
4545 changeDetection : ChangeDetectionStrategy . OnPush ,
4646 encapsulation : ViewEncapsulation . None ,
4747} )
48- export class MdSidenav {
48+ export class MdSidenav implements AfterContentInit {
4949 /** Alignment of the sidenav (direction neutral); whether 'start' or 'end'. */
5050 @Input ( ) align : 'start' | 'end' = 'start' ;
5151
@@ -73,6 +73,15 @@ export class MdSidenav {
7373 */
7474 constructor ( private _elementRef : ElementRef ) { }
7575
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+
7685 /**
7786 * Whether the sidenav is opened. We overload this because we trigger an event when it
7887 * starts or end.
You can’t perform that action at this time.
0 commit comments