@@ -25,7 +25,7 @@ import {Subject} from 'rxjs/Subject';
25
25
import 'rxjs/add/observable/merge' ;
26
26
import 'rxjs/add/operator/startWith' ;
27
27
import 'rxjs/add/operator/switchMap' ;
28
- import { MdInputContainer , FloatPlaceholderType } from '../input/input-container' ;
28
+ import { MdInputContainer } from '../input/input-container' ;
29
29
30
30
/**
31
31
* The following style constants are necessary to save here in order
@@ -81,6 +81,9 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
81
81
/** Stream of blur events that should close the panel. */
82
82
private _blurStream = new Subject < any > ( ) ;
83
83
84
+ /** Whether or not the placeholder state is being overridden. */
85
+ private _manuallyFloatingPlaceholder = false ;
86
+
84
87
/** View -> model callback called when value changes */
85
88
_onChange = ( value : any ) => { } ;
86
89
@@ -134,7 +137,7 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
134
137
}
135
138
136
139
this . _panelOpen = true ;
137
- this . _floatPlaceholder ( 'always' ) ;
140
+ this . _floatPlaceholder ( ) ;
138
141
}
139
142
140
143
/** Closes the autocomplete suggestion panel. */
@@ -144,7 +147,7 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
144
147
}
145
148
146
149
this . _panelOpen = false ;
147
- this . _floatPlaceholder ( 'auto' ) ;
150
+ this . _resetPlaceholder ( ) ;
148
151
}
149
152
150
153
/**
@@ -237,9 +240,18 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
237
240
* This causes the value to jump when selecting an option with the mouse.
238
241
* This method manually floats the placeholder until the panel can be closed.
239
242
*/
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 ;
243
255
}
244
256
}
245
257
0 commit comments