Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InputField] Autocomplete/Autofill value [ By Browser password manger] overlap by InputLabel. #8

Closed
k-e-r opened this issue Jun 10, 2022 · 1 comment

Comments

@k-e-r
Copy link
Contributor

k-e-r commented Jun 10, 2022

This issue is the same as "mui/material-ui/issues/24756".
I'm making this function from scratch without mui. I'll refer to this one and solve it.

k-e-r referenced this issue in k-e-r/TimeTracker-App Jun 10, 2022
@k-e-r k-e-r mentioned this issue Jun 10, 2022
@k-e-r
Copy link
Contributor Author

k-e-r commented Jun 10, 2022

The above ticket is a duplicate of this one. Mentioned just in case.
"mui/material-ui/issues/22488"

Also, the comments here were very helpful.
"mui/material-ui/issues/22488#issuecomment-687293183"

I considered putting a value in the input value from the beginning, but I wanted to avoid this from a UX perspective, so I implemented the following countermeasure.

// for Chrome

useEffect(() => {
  const interval = setInterval(() => {
    try {
      const detect = document.querySelectorAll(
        ':-internal-autofill-selected'
      );
      if (detect.length === 2) {
        // change label size(add css class)
        setEmailLabelCss('rInputLabelActive');
        setPassLabelCss('rInputLabelActive');
      } else if (detect[0].type === 'email') {
        setEmailLabelCss('rInputLabelActive');
      } else {
        setPassLabelCss('rInputLabelActive');
      }
    } catch (error) {
      console.log('error:', error);
    }

    clearInterval(interval);
  }, 500);
  return () => clearInterval(interval);
}, []);

The "else if" and after are unlikely to be considered, but are included just in case.

// for other browser - CSS

input:-webkit-autofill ~ .rInputLabel {
  transform: translate(14px, 7px) scale(0.75);
}
input:autofill ~ .rInputLabel {
  transform: translate(14px, 7px) scale(0.75);
}
  • HTML
<div>
  <input />
  <label>
    // e.g. email
  </label>
</div>

Chrome: Version 102.0.5005.61 (Official Build) (arm64)
Safari: Version 15.0 (16612.1.29.41.4, 16612)
Firefox: 101.0.1 (64 ビット)

@k-e-r k-e-r closed this as completed Jun 10, 2022
k-e-r referenced this issue in k-e-r/TimeTracker-App Jun 11, 2022
Disable autofill at Register and extend autofill response time delay at Login(#8)
yoshino9397 pushed a commit that referenced this issue Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant