This repository was archived by the owner on Jan 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -191,13 +191,28 @@ class MDCTextfieldFoundation extends MDCFoundation {
191
191
}
192
192
193
193
/**
194
+ * Changes the floating label's state
194
195
* @private
195
196
*/
196
- forceLayout_ ( ) {
197
- // Don't do anything if the input is still focused.
197
+ updateLabelFloat_ ( ) {
198
+ // Don't do anything if the input is focused.
198
199
if ( ! this . isFocused_ ) {
199
- this . activateFocus_ ( ) ;
200
- this . deactivateFocus_ ( ) ;
200
+ const { LABEL_FLOAT_ABOVE , LABEL_SHAKE } = MDCTextfieldFoundation . cssClasses ;
201
+ const input = this . getNativeInput_ ( ) ;
202
+
203
+ this . adapter_ . removeClassFromLabel ( LABEL_SHAKE ) ;
204
+ this . showHelptext_ ( ) ;
205
+
206
+ if ( input . value ) {
207
+ this . adapter_ . addClassToLabel ( LABEL_FLOAT_ABOVE ) ;
208
+ }
209
+ else {
210
+ this . adapter_ . removeClassFromLabel ( LABEL_FLOAT_ABOVE ) ;
211
+ }
212
+
213
+ if ( ! this . useCustomValidityChecking_ ) {
214
+ this . changeValidity_ ( input . checkValidity ( ) ) ;
215
+ }
201
216
}
202
217
}
203
218
@@ -366,7 +381,7 @@ class MDCTextfieldFoundation extends MDCFoundation {
366
381
get : desc . get ,
367
382
set : ( value ) => {
368
383
desc . set . call ( nativeInputElement , value ) ;
369
- this . forceLayout_ ( ) ;
384
+ this . updateLabelFloat_ ( ) ;
370
385
} ,
371
386
configurable : desc . configurable ,
372
387
enumerable : desc . enumerable ,
You can’t perform that action at this time.
0 commit comments