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

fix: enable sign in button when firefox autofills credentials #1651

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/components/Signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const Signin = () => {

// Handle clicks outside the dropdown
useEffect(() => {
// Handle clicks outside the dropdown
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownRef.current &&
Expand All @@ -159,12 +160,30 @@ const Signin = () => {
setSuggestedDomains([]);
}
};

document.addEventListener('mousedown', handleClickOutside);

// Check for autofill on component mount
const checkAutofill = () => {
const emailField = document.getElementById('email') as HTMLInputElement;
const passwordField = document.getElementById('password') as HTMLInputElement;

if (emailField?.value) {
email.current = emailField.value;
setRequiredError((prevState) => ({ ...prevState, emailReq: false }));
}

if (passwordField?.value) {
password.current = passwordField.value;
setRequiredError((prevState) => ({ ...prevState, passReq: false }));
}
};
document.addEventListener('mousedown', handleClickOutside);
const autofillTimeout = setTimeout(checkAutofill, 100);

return () => {
document.removeEventListener('mousedown', handleClickOutside);
clearTimeout(autofillTimeout);
};
}, []);
}, []);

return (
<section className="wrapper relative flex min-h-screen items-center justify-center overflow-hidden antialiased">
Expand Down Expand Up @@ -201,6 +220,7 @@ const Signin = () => {
placeholder="[email protected]"
value={email.current}
onChange={handleEmailChange}
onInput={handleEmailChange}
onKeyDown={handleKeyDown}
onBlur={() => setSuggestedDomains([])} // Hide suggestions on blur
/>
Expand Down