fix: Password toggle triggering on Enter when checkbox is focused (#767)

This commit is contained in:
Aman Harwara
2021-12-09 23:18:52 +05:30
committed by GitHub
parent 0f05da435c
commit 024d44f1ff

View File

@@ -34,7 +34,7 @@ export const SignInPane: FunctionComponent<Props> = observer(
useEffect(() => { useEffect(() => {
if (emailInputRef?.current) { if (emailInputRef?.current) {
emailInputRef.current!.focus(); emailInputRef.current?.focus();
} }
}, []); }, []);
@@ -73,8 +73,8 @@ export const SignInPane: FunctionComponent<Props> = observer(
const signIn = () => { const signIn = () => {
setIsSigningIn(true); setIsSigningIn(true);
emailInputRef?.current!.blur(); emailInputRef?.current?.blur();
passwordInputRef?.current!.blur(); passwordInputRef?.current?.blur();
application application
.signIn(email, password, isStrictSignin, isEphemeral, shouldMergeLocal) .signIn(email, password, isStrictSignin, isEphemeral, shouldMergeLocal)
@@ -92,7 +92,7 @@ export const SignInPane: FunctionComponent<Props> = observer(
application.alertService.alert(err); application.alertService.alert(err);
} }
setPassword(''); setPassword('');
passwordInputRef?.current!.blur(); passwordInputRef?.current?.blur();
}) })
.finally(() => { .finally(() => {
setIsSigningIn(false); setIsSigningIn(false);
@@ -109,12 +109,12 @@ export const SignInPane: FunctionComponent<Props> = observer(
e.preventDefault(); e.preventDefault();
if (!email || email.length === 0) { if (!email || email.length === 0) {
emailInputRef?.current!.focus(); emailInputRef?.current?.focus();
return; return;
} }
if (!password || password.length === 0) { if (!password || password.length === 0) {
passwordInputRef?.current!.focus(); passwordInputRef?.current?.focus();
return; return;
} }
@@ -134,7 +134,6 @@ export const SignInPane: FunctionComponent<Props> = observer(
/> />
<div className="sn-account-menu-headline">Sign in</div> <div className="sn-account-menu-headline">Sign in</div>
</div> </div>
<form onSubmit={handleSignInFormSubmit}>
<div className="px-3 mb-1"> <div className="px-3 mb-1">
<InputWithIcon <InputWithIcon
className={`mb-2 ${isInvalid ? 'border-dark-red' : null}`} className={`mb-2 ${isInvalid ? 'border-dark-red' : null}`}
@@ -196,7 +195,6 @@ export const SignInPane: FunctionComponent<Props> = observer(
/> />
) : null} ) : null}
</div> </div>
</form>
<div className="h-1px my-2 bg-border"></div> <div className="h-1px my-2 bg-border"></div>
<AdvancedOptions <AdvancedOptions
appState={appState} appState={appState}