From 440483635578bf88a51b0073926f0b3d7d6b80b2 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Thu, 9 Dec 2021 21:50:54 +0530 Subject: [PATCH] fix: Password toggle triggering on Enter when checkbox is focused --- .../components/AccountMenu/SignIn.tsx | 130 +++++++++--------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/app/assets/javascripts/components/AccountMenu/SignIn.tsx b/app/assets/javascripts/components/AccountMenu/SignIn.tsx index 9c187890c53..f4bb3cf1426 100644 --- a/app/assets/javascripts/components/AccountMenu/SignIn.tsx +++ b/app/assets/javascripts/components/AccountMenu/SignIn.tsx @@ -34,7 +34,7 @@ export const SignInPane: FunctionComponent = observer( useEffect(() => { if (emailInputRef?.current) { - emailInputRef.current!.focus(); + emailInputRef.current?.focus(); } }, []); @@ -73,8 +73,8 @@ export const SignInPane: FunctionComponent = observer( const signIn = () => { setIsSigningIn(true); - emailInputRef?.current!.blur(); - passwordInputRef?.current!.blur(); + emailInputRef?.current?.blur(); + passwordInputRef?.current?.blur(); application .signIn(email, password, isStrictSignin, isEphemeral, shouldMergeLocal) @@ -92,7 +92,7 @@ export const SignInPane: FunctionComponent = observer( application.alertService.alert(err); } setPassword(''); - passwordInputRef?.current!.blur(); + passwordInputRef?.current?.blur(); }) .finally(() => { setIsSigningIn(false); @@ -109,12 +109,12 @@ export const SignInPane: FunctionComponent = observer( e.preventDefault(); if (!email || email.length === 0) { - emailInputRef?.current!.focus(); + emailInputRef?.current?.focus(); return; } if (!password || password.length === 0) { - passwordInputRef?.current!.focus(); + passwordInputRef?.current?.focus(); return; } @@ -134,69 +134,67 @@ export const SignInPane: FunctionComponent = observer( />
Sign in
-
-
- - - {isInvalid ? ( -
- Invalid email or password. -
- ) : null} -
-
+ ) : null} +