Skip to content

Instantly share code, notes, and snippets.

@prince-neres
Created November 27, 2024 16:37
Show Gist options
  • Select an option

  • Save prince-neres/7a2da30d4c2904cf299381beee0c76e0 to your computer and use it in GitHub Desktop.

Select an option

Save prince-neres/7a2da30d4c2904cf299381beee0c76e0 to your computer and use it in GitHub Desktop.
Disable show password icon in browser autocomplete
<style>
#_com_liferay_login_web_portlet_LoginPortlet_password:-webkit-autofill {
animation: autofill-detect 0.001s both;
}
@keyframes autofill-detect {
from {
background-color: #fff;
}
to {
background-color: #fff;
}
}
.disabled-eye {
pointer-events: none;
color: gray;
}
</style>
<script>
document.addEventListener("animationstart", (event) => {
if (event.animationName === "autofill-detect") {
const passwordInput = event.target;
let showPasswordIcon = passwordInput.parentElement.querySelector(".icon-eye-close");
if (!showPasswordIcon) {
passwordInput.type = "password";
showPasswordIcon = passwordInput.parentElement.querySelector(".icon-eye-open");
showPasswordIcon.classList.remove("icon-eye-open");
showPasswordIcon.classList.add("icon-eye-close");
}
showPasswordIcon.style.pointerEvents = "none";
showPasswordIcon.classList.add("disabled-eye");
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment