@@ -47,7 +47,9 @@ describe('MdSelect', () => {
47
47
BasicSelectOnPush ,
48
48
BasicSelectOnPushPreselected ,
49
49
SelectWithPlainTabindex ,
50
- SelectEarlyAccessSibling
50
+ SelectEarlyAccessSibling ,
51
+ BasicSelectInitiallyHidden ,
52
+ BasicSelectNoPlaceholder
51
53
] ,
52
54
providers : [
53
55
{ provide : OverlayContainer , useFactory : ( ) => {
@@ -159,6 +161,25 @@ describe('MdSelect', () => {
159
161
} ) ;
160
162
} ) ) ;
161
163
164
+ it ( 'should set the width of the overlay if the element was hidden initially' , async ( ( ) => {
165
+ let initiallyHidden = TestBed . createComponent ( BasicSelectInitiallyHidden ) ;
166
+
167
+ initiallyHidden . detectChanges ( ) ;
168
+ trigger = initiallyHidden . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
169
+ trigger . style . width = '200px' ;
170
+
171
+ initiallyHidden . componentInstance . isVisible = true ;
172
+ initiallyHidden . detectChanges ( ) ;
173
+
174
+ initiallyHidden . whenStable ( ) . then ( ( ) => {
175
+ trigger . click ( ) ;
176
+ initiallyHidden . detectChanges ( ) ;
177
+
178
+ const pane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
179
+ expect ( pane . style . minWidth ) . toBe ( '200px' ) ;
180
+ } ) ;
181
+ } ) ) ;
182
+
162
183
it ( 'should not attempt to open a select that does not have any options' , ( ) => {
163
184
fixture . componentInstance . foods = [ ] ;
164
185
fixture . detectChanges ( ) ;
@@ -169,6 +190,21 @@ describe('MdSelect', () => {
169
190
expect ( fixture . componentInstance . select . panelOpen ) . toBe ( false ) ;
170
191
} ) ;
171
192
193
+ it ( 'should set the width of the overlay if there is no placeholder' , async ( ( ) => {
194
+ let noPlaceholder = TestBed . createComponent ( BasicSelectNoPlaceholder ) ;
195
+
196
+ noPlaceholder . detectChanges ( ) ;
197
+ trigger = noPlaceholder . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
198
+
199
+ noPlaceholder . whenStable ( ) . then ( ( ) => {
200
+ trigger . click ( ) ;
201
+ noPlaceholder . detectChanges ( ) ;
202
+
203
+ const pane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
204
+ expect ( parseInt ( pane . style . minWidth ) ) . toBeGreaterThan ( 0 ) ;
205
+ } ) ;
206
+ } ) ) ;
207
+
172
208
} ) ;
173
209
174
210
describe ( 'selection logic' , ( ) => {
@@ -1957,6 +1993,27 @@ class SelectWithPlainTabindex { }
1957
1993
} )
1958
1994
class SelectEarlyAccessSibling { }
1959
1995
1996
+ @Component ( {
1997
+ selector : 'basic-select-initially-hidden' ,
1998
+ template : `
1999
+ <md-select [style.display]="isVisible ? 'block' : 'none'">
2000
+ <md-option value="value">There are no other options</md-option>
2001
+ </md-select>
2002
+ `
2003
+ } )
2004
+ class BasicSelectInitiallyHidden {
2005
+ isVisible = false ;
2006
+ }
2007
+
2008
+ @Component ( {
2009
+ selector : 'basic-select-no-placeholder' ,
2010
+ template : `
2011
+ <md-select>
2012
+ <md-option value="value">There are no other options</md-option>
2013
+ </md-select>
2014
+ `
2015
+ } )
2016
+ class BasicSelectNoPlaceholder { }
1960
2017
1961
2018
class FakeViewportRuler {
1962
2019
getViewportRect ( ) {
0 commit comments