@@ -43,7 +43,8 @@ describe('MdSelect', () => {
4343 ThrowsErrorOnInit ,
4444 BasicSelectOnPush ,
4545 BasicSelectOnPushPreselected ,
46- SelectWithPlainTabindex
46+ SelectWithPlainTabindex ,
47+ BasicSelectInitiallyHidden
4748 ] ,
4849 providers : [
4950 { provide : OverlayContainer , useFactory : ( ) => {
@@ -155,6 +156,25 @@ describe('MdSelect', () => {
155156 } ) ;
156157 } ) ) ;
157158
159+ it ( 'should set the width of the overlay if the element was hidden initially' , async ( ( ) => {
160+ let initiallyHidden = TestBed . createComponent ( BasicSelectInitiallyHidden ) ;
161+
162+ initiallyHidden . detectChanges ( ) ;
163+ trigger = initiallyHidden . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
164+ trigger . style . width = '200px' ;
165+
166+ initiallyHidden . componentInstance . isVisible = true ;
167+ initiallyHidden . detectChanges ( ) ;
168+
169+ initiallyHidden . whenStable ( ) . then ( ( ) => {
170+ trigger . click ( ) ;
171+ initiallyHidden . detectChanges ( ) ;
172+
173+ const pane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
174+ expect ( pane . style . minWidth ) . toBe ( '200px' ) ;
175+ } ) ;
176+ } ) ) ;
177+
158178 it ( 'should not attempt to open a select that does not have any options' , ( ) => {
159179 fixture . componentInstance . foods = [ ] ;
160180 fixture . detectChanges ( ) ;
@@ -1893,6 +1913,18 @@ class MultiSelect {
18931913} )
18941914class SelectWithPlainTabindex { }
18951915
1916+ @Component ( {
1917+ selector : 'basic-select-initially-hidden' ,
1918+ template : `
1919+ <md-select [style.display]="isVisible ? 'block' : 'none'">
1920+ <md-option value="value">There are no other options</md-option>
1921+ </md-select>
1922+ `
1923+ } )
1924+ class BasicSelectInitiallyHidden {
1925+ isVisible = false ;
1926+ }
1927+
18961928
18971929class FakeViewportRuler {
18981930 getViewportRect ( ) {
0 commit comments