@@ -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  /** 
@@ -232,9 +235,18 @@ 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 . _inputContainer . floatPlaceholder  =  'always' ; 
241+       this . _manuallyFloatingPlaceholder  =  true ; 
242+     } 
243+   } 
244+ 
245+   /** If the placeholder has been manually elevated, return it to its normal state. */ 
246+   private  _resetPlaceholder ( ) : void { 
247+     if  ( this . _manuallyFloatingPlaceholder )  { 
248+       this . _inputContainer . floatPlaceholder  =  'auto' ; 
249+       this . _manuallyFloatingPlaceholder  =  false ; 
238250    } 
239251  } 
240252
0 commit comments