@@ -47,7 +47,9 @@ describe('MdSelect', () => {
4747 BasicSelectOnPush ,
4848 BasicSelectOnPushPreselected ,
4949 SelectWithPlainTabindex ,
50- SelectEarlyAccessSibling
50+ SelectEarlyAccessSibling ,
51+ BasicSelectInitiallyHidden ,
52+ BasicSelectNoPlaceholder
5153 ] ,
5254 providers : [
5355 { provide : OverlayContainer , useFactory : ( ) => {
@@ -159,6 +161,25 @@ describe('MdSelect', () => {
159161 } ) ;
160162 } ) ) ;
161163
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+
162183 it ( 'should not attempt to open a select that does not have any options' , ( ) => {
163184 fixture . componentInstance . foods = [ ] ;
164185 fixture . detectChanges ( ) ;
@@ -169,6 +190,21 @@ describe('MdSelect', () => {
169190 expect ( fixture . componentInstance . select . panelOpen ) . toBe ( false ) ;
170191 } ) ;
171192
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+
172208 } ) ;
173209
174210 describe ( 'selection logic' , ( ) => {
@@ -1967,6 +2003,27 @@ class SelectWithPlainTabindex { }
19672003} )
19682004class SelectEarlyAccessSibling { }
19692005
2006+ @Component ( {
2007+ selector : 'basic-select-initially-hidden' ,
2008+ template : `
2009+ <md-select [style.display]="isVisible ? 'block' : 'none'">
2010+ <md-option value="value">There are no other options</md-option>
2011+ </md-select>
2012+ `
2013+ } )
2014+ class BasicSelectInitiallyHidden {
2015+ isVisible = false ;
2016+ }
2017+
2018+ @Component ( {
2019+ selector : 'basic-select-no-placeholder' ,
2020+ template : `
2021+ <md-select>
2022+ <md-option value="value">There are no other options</md-option>
2023+ </md-select>
2024+ `
2025+ } )
2026+ class BasicSelectNoPlaceholder { }
19702027
19712028class FakeViewportRuler {
19722029 getViewportRect ( ) {
0 commit comments