@@ -71,6 +71,9 @@ export class MdSelect implements AfterContentInit, ControlValueAccessor, OnDestr
7171 /** Whether the select is disabled. */
7272 private _disabled : boolean = false ;
7373
74+ /** The animation state of the placeholder. */
75+ _placeholderState = '' ;
76+
7477 /** Manages keyboard events for options in the panel. */
7578 _keyManager : ListKeyManager ;
7679
@@ -163,12 +166,16 @@ export class MdSelect implements AfterContentInit, ControlValueAccessor, OnDestr
163166 if ( this . disabled ) {
164167 return ;
165168 }
169+ this . _placeholderState = this . _isRtl ( ) ? 'floating-rtl' : 'floating-ltr' ;
166170 this . _panelOpen = true ;
167171 }
168172
169173 /** Closes the overlay panel and focuses the host element. */
170174 close ( ) : void {
171175 this . _panelOpen = false ;
176+ if ( ! this . _selected ) {
177+ this . _placeholderState = '' ;
178+ }
172179 this . _focusHost ( ) ;
173180 }
174181
@@ -182,7 +189,7 @@ export class MdSelect implements AfterContentInit, ControlValueAccessor, OnDestr
182189 // the select's child options have been created. It's necessary to call
183190 // writeValue() again after the options have been created to ensure any
184191 // initial view value is set.
185- this . _ngZone . onStable . first ( ) . subscribe ( ( ) => this . writeValue ( value ) ) ;
192+ this . _ngZone . onMicrotaskEmpty . first ( ) . subscribe ( ( ) => this . writeValue ( value ) ) ;
186193 return ;
187194 }
188195
@@ -240,15 +247,6 @@ export class MdSelect implements AfterContentInit, ControlValueAccessor, OnDestr
240247 return this . trigger . nativeElement . getBoundingClientRect ( ) . width ;
241248 }
242249
243- /** The animation state of the placeholder. */
244- _getPlaceholderState ( ) : string {
245- if ( this . panelOpen || this . selected ) {
246- return this . _isRtl ( ) ? 'floating-rtl' : 'floating-ltr' ;
247- } else {
248- return 'normal' ;
249- }
250- }
251-
252250 /** The animation state of the overlay panel. */
253251 _getPanelState ( ) : string {
254252 return this . _isRtl ( ) ? `${ this . _transformOrigin } -rtl` : `${ this . _transformOrigin } -ltr` ;
@@ -340,7 +338,9 @@ export class MdSelect implements AfterContentInit, ControlValueAccessor, OnDestr
340338 private _onSelect ( option : MdOption ) : void {
341339 this . _selected = option ;
342340 this . _updateOptions ( ) ;
343- this . close ( ) ;
341+ if ( this . panelOpen ) {
342+ this . close ( ) ;
343+ }
344344 }
345345
346346 /** Deselect each option that doesn't match the current selection. */
0 commit comments