question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] bug(text-field, notched-outline): Chrome autofill doesn't work with outline variant

See original GitHub issue

Hi,

there is still a problem with autofilling of credentials in Chrome, when the outlined variant of textfields is used:

grafik

There was already an issue (#137) for the non-outlined variant, which was solved in #180:

https://github.com/material-components/material-components-web/blob/70672f12ff19591c53fef6876c059c854f9cb816/packages/mdc-textfield/mdc-text-field.scss#L134-L138 (Please note that the filename has changed after the PR.)

As in the outline variant more classes and combinations of classes are involved for the filled state, there’ll be more CSS selectors with * &:-webkit-autofill, as well as more JS needed, as far as I can guess without having a deeper look into the library/SCSS files.

What MDC Web Version are you using?

0.44.1

What browser(s) is this bug affecting?

It’s only a problem with Chrome, Firefox still sends a change event. I can’t say anything about the other browsers at the moment as I haven’t tested them.

What are the steps to reproduce the bug?

Create a form with a textfield for username and password while using the outlined variant. Then open it in Chrome, type in some credentials, save them with Chrome and reload the page.

Hints:

  • Chrome doesn’t ask for saving the credentials when it’s a local path.
  • Do not click around in the page as this will cause the labels to be updated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
TheCom3di4ncommented, May 13, 2019

Hi @abhiomkar, first of all, I want to note that I also had a time when I couldn’t reproduce the bug, but I was unsure if it wasn’t me. Unfortunately, I can’t remember the Chrome version I was using at the time.

But now I can reproduce it again. We also tested it on two independent computers. (Same version of Chrome)

image

Version of Chrome: 74.0.3729.131 Version of material-components-web: latest@05/13/2019

Oh, and I can’t reopen the issue because I don’t have the necessary rights.

4reactions
pangolingocommented, Feb 25, 2019

I’ve been investigating this in our codebase and put together this hacky quickfix. There’s got to be a better way to handle it.

window.setTimeout(() => {
  document
    .querySelectorAll('.mdc-text-field__input:-webkit-autofill')
    .forEach(el => {
      const textField = el.parentNode;
      const label = textField.querySelector('.mdc-floating-label');
      if (label) {
        label.classList.add('mdc-floating-label--float-above');
      }
      if (textField.MDCTextField) {
        textField.MDCTextField.foundation_.notchOutline(true);
      }
    });
}, 300);
Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Setting text color, outline, and padding on Material-ui ...
We have a similar issue for the notchedOutline style within an AutoComplete component. This can be customized via the InputProps param and works...
Read more >
How to Change MUI TextField's Border Color (Hover, Focus ...
Here are all the features this post covers: MUI Input border color; Disabled TextField border color; Outlined variant TextField border color – ...
Read more >
Text fields - Material Design
Filled text fields (with suffix text) can display the following states: inactive, activated, focused, hover, error, and disabled. Outlined text field link ...
Read more >
@material/mwc-textfield - npm
IMPORTANT: The Material Web Components are a work in progress and subject to major changes until 1.0 release. Text fields let users enter...
Read more >
OutlinedInput API - Material UI - MUI
The name can be confusing, as it's more like an autofill. ... If true , the input element is focused during the first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found