@@ -43,7 +43,8 @@ describe('MdSelect', () => {
43
43
ThrowsErrorOnInit ,
44
44
BasicSelectOnPush ,
45
45
BasicSelectOnPushPreselected ,
46
- SelectWithPlainTabindex
46
+ SelectWithPlainTabindex ,
47
+ BasicSelectInitiallyHidden
47
48
] ,
48
49
providers : [
49
50
{ provide : OverlayContainer , useFactory : ( ) => {
@@ -155,6 +156,25 @@ describe('MdSelect', () => {
155
156
} ) ;
156
157
} ) ) ;
157
158
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
+
158
178
it ( 'should not attempt to open a select that does not have any options' , ( ) => {
159
179
fixture . componentInstance . foods = [ ] ;
160
180
fixture . detectChanges ( ) ;
@@ -1893,6 +1913,18 @@ class MultiSelect {
1893
1913
} )
1894
1914
class SelectWithPlainTabindex { }
1895
1915
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
+
1896
1928
1897
1929
class FakeViewportRuler {
1898
1930
getViewportRect ( ) {
0 commit comments