HTML
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> <input class="mdl-textfield__input" type="password" id="password" required name="password"> <label class="mdl-textfield__label" for="password"></label> </div>
CSS fix
.mdl-textfield--floating-label input[type=password]:-webkit-autofill ~ label { transform: translate3d(0, -20px, 0); visibility: hidden; } .mdl-textfield--floating-label input[type=password]:-webkit-autofill ~ label:after { content: 'Password'; visibility: visible; left: 0; transform: translate3d(0, -20px, 0); background: transparent; color: inherit; }
Change the color and possibly px offset according to your needs
A jQuery solution that works when the type is not a "password"
$.each($('.mdl-textfield__input'), function() { $(this).parent().get(0).MaterialTextfield.checkDirty(); });
Another way to bypass jquery is to force focus on the input field if autocomplete is detected. You should put this inside $ (document) .ready
setTimeout(function() { try { if ( $('#password:-webkit-autofill').length > 0 ) $('#password').focus(); } catch (error) { console.log(error); } }, 25);
source share