@@ -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 /**
@@ -232,12 +235,26 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
232235 * This causes the value to jump when selecting an option with the mouse.
233236 * This method manually floats the placeholder until the panel can be closed.
234237 */
235- private _floatPlaceholder ( state : FloatPlaceholderType ) : void {
236- if ( this . _inputContainer ) {
237- this . _inputContainer . floatPlaceholder = state ;
238+ private _floatPlaceholder ( ) : void {
239+ if ( this . _inputContainer && this . _inputContainer . floatPlaceholder === 'auto' ) {
240+ this . _setPlaceholderState ( 'always' ) ;
241+ }
242+ }
243+
244+ /** If the placeholder has been manually elevated, return it to its normal state. */
245+ private _resetPlaceholder ( ) : void {
246+ if ( this . _manuallyFloatingPlaceholder ) {
247+ this . _setPlaceholderState ( 'auto' ) ;
248+ this . _manuallyFloatingPlaceholder = false ;
238249 }
239250 }
240251
252+ /** Sets the placeholder state of the input manually. */
253+ private _setPlaceholderState ( state : FloatPlaceholderType ) : void {
254+ this . _manuallyFloatingPlaceholder = true ;
255+ this . _inputContainer . floatPlaceholder = state ;
256+ }
257+
241258 /**
242259 * Given that we are not actually focusing active options, we must manually adjust scroll
243260 * to reveal options below the fold. First, we find the offset of the option from the top
0 commit comments