@@ -43,7 +43,9 @@ describe('MdSelect', () => {
43
43
ThrowsErrorOnInit ,
44
44
BasicSelectOnPush ,
45
45
BasicSelectOnPushPreselected ,
46
- SelectWithPlainTabindex
46
+ SelectWithPlainTabindex ,
47
+ BasicSelectInitiallyHidden ,
48
+ BasicSelectNoPlaceholder
47
49
] ,
48
50
providers : [
49
51
{ provide : OverlayContainer , useFactory : ( ) => {
@@ -155,6 +157,25 @@ describe('MdSelect', () => {
155
157
} ) ;
156
158
} ) ) ;
157
159
160
+ it ( 'should set the width of the overlay if the element was hidden initially' , async ( ( ) => {
161
+ let initiallyHidden = TestBed . createComponent ( BasicSelectInitiallyHidden ) ;
162
+
163
+ initiallyHidden . detectChanges ( ) ;
164
+ trigger = initiallyHidden . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
165
+ trigger . style . width = '200px' ;
166
+
167
+ initiallyHidden . componentInstance . isVisible = true ;
168
+ initiallyHidden . detectChanges ( ) ;
169
+
170
+ initiallyHidden . whenStable ( ) . then ( ( ) => {
171
+ trigger . click ( ) ;
172
+ initiallyHidden . detectChanges ( ) ;
173
+
174
+ const pane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
175
+ expect ( pane . style . minWidth ) . toBe ( '200px' ) ;
176
+ } ) ;
177
+ } ) ) ;
178
+
158
179
it ( 'should not attempt to open a select that does not have any options' , ( ) => {
159
180
fixture . componentInstance . foods = [ ] ;
160
181
fixture . detectChanges ( ) ;
@@ -165,6 +186,21 @@ describe('MdSelect', () => {
165
186
expect ( fixture . componentInstance . select . panelOpen ) . toBe ( false ) ;
166
187
} ) ;
167
188
189
+ it ( 'should set the width of the overlay if there is no placeholder' , async ( ( ) => {
190
+ let noPlaceholder = TestBed . createComponent ( BasicSelectNoPlaceholder ) ;
191
+
192
+ noPlaceholder . detectChanges ( ) ;
193
+ trigger = noPlaceholder . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
194
+
195
+ noPlaceholder . whenStable ( ) . then ( ( ) => {
196
+ trigger . click ( ) ;
197
+ noPlaceholder . detectChanges ( ) ;
198
+
199
+ const pane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
200
+ expect ( parseInt ( pane . style . minWidth ) ) . toBeGreaterThan ( 0 ) ;
201
+ } ) ;
202
+ } ) ) ;
203
+
168
204
} ) ;
169
205
170
206
describe ( 'selection logic' , ( ) => {
@@ -1893,6 +1929,27 @@ class MultiSelect {
1893
1929
} )
1894
1930
class SelectWithPlainTabindex { }
1895
1931
1932
+ @Component ( {
1933
+ selector : 'basic-select-initially-hidden' ,
1934
+ template : `
1935
+ <md-select [style.display]="isVisible ? 'block' : 'none'">
1936
+ <md-option value="value">There are no other options</md-option>
1937
+ </md-select>
1938
+ `
1939
+ } )
1940
+ class BasicSelectInitiallyHidden {
1941
+ isVisible = false ;
1942
+ }
1943
+
1944
+ @Component ( {
1945
+ selector : 'basic-select-no-placeholder' ,
1946
+ template : `
1947
+ <md-select>
1948
+ <md-option value="value">There are no other options</md-option>
1949
+ </md-select>
1950
+ `
1951
+ } )
1952
+ class BasicSelectNoPlaceholder { }
1896
1953
1897
1954
class FakeViewportRuler {
1898
1955
getViewportRect ( ) {
0 commit comments