@@ -25,7 +25,7 @@ import {Subject} from 'rxjs/Subject';
2525import 'rxjs/add/observable/merge' ;
2626import 'rxjs/add/operator/startWith' ;
2727import 'rxjs/add/operator/switchMap' ;
28- import { MdInputContainer , FloatPlaceholderType } from '../input/input-container' ;
28+ import { MdInputContainer } from '../input/input-container' ;
2929
3030/**
3131 * The following style constants are necessary to save here in order
@@ -81,6 +81,9 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
8181 /** Stream of blur events that should close the panel. */
8282 private _blurStream = new Subject < any > ( ) ;
8383
84+ /** Whether or not the placeholder state is being overridden. */
85+ private _manuallyFloatingPlaceholder = false ;
86+
8487 /** View -> model callback called when value changes */
8588 _onChange = ( value : any ) => { } ;
8689
@@ -134,7 +137,7 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
134137 }
135138
136139 this . _panelOpen = true ;
137- this . _floatPlaceholder ( 'always' ) ;
140+ this . _floatPlaceholder ( ) ;
138141 }
139142
140143 /** Closes the autocomplete suggestion panel. */
@@ -144,7 +147,7 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
144147 }
145148
146149 this . _panelOpen = false ;
147- this . _floatPlaceholder ( 'auto' ) ;
150+ this . _resetPlaceholder ( ) ;
148151 }
149152
150153 /**
@@ -237,9 +240,18 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
237240 * This causes the value to jump when selecting an option with the mouse.
238241 * This method manually floats the placeholder until the panel can be closed.
239242 */
240- private _floatPlaceholder ( state : FloatPlaceholderType ) : void {
241- if ( this . _inputContainer ) {
242- this . _inputContainer . floatPlaceholder = state ;
243+ private _floatPlaceholder ( ) : void {
244+ if ( this . _inputContainer && this . _inputContainer . floatPlaceholder === 'auto' ) {
245+ this . _inputContainer . floatPlaceholder = 'always' ;
246+ this . _manuallyFloatingPlaceholder = true ;
247+ }
248+ }
249+
250+ /** If the placeholder has been manually elevated, return it to its normal state. */
251+ private _resetPlaceholder ( ) : void {
252+ if ( this . _manuallyFloatingPlaceholder ) {
253+ this . _inputContainer . floatPlaceholder = 'auto' ;
254+ this . _manuallyFloatingPlaceholder = false ;
243255 }
244256 }
245257
0 commit comments