diff --git a/packages/web-ui-registration/src/LoginForm.tsx b/packages/web-ui-registration/src/LoginForm.tsx index 24ad530f50155..17a513b9b894a 100644 --- a/packages/web-ui-registration/src/LoginForm.tsx +++ b/packages/web-ui-registration/src/LoginForm.tsx @@ -73,15 +73,12 @@ export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRoute }, onError: (error: any) => { if ([error.error, error.errorType].includes('error-invalid-email')) { - setError('username', { type: 'invalid-email', message: t('registration.page.login.errors.invalidEmail') }); + return setError('username', { type: 'invalid-email', message: t('registration.page.login.errors.invalidEmail') }); } if ('error' in error && error.error !== 403) { - setErrorOnSubmit(error.error); - return; + return setErrorOnSubmit(error.error); } - - setErrorOnSubmit('user-not-found'); }, }); @@ -93,11 +90,15 @@ export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRoute if (loginFormRef.current) { loginFormRef.current.focus(); } - }, [errorOnSubmit]); + }, []); const renderErrorOnSubmit = (error: LoginErrors) => { const { type, i18n } = LOGIN_SUBMIT_ERRORS[error]; - return {t(i18n)}; + return ( + + {t(i18n)} + + ); }; if (errors.username?.type === 'invalid-email') { @@ -131,7 +132,7 @@ export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRoute placeholder={usernameOrEmailPlaceholder || t('registration.component.form.emailPlaceholder')} error={errors.username?.message} aria-invalid={errors.username || errorOnSubmit ? 'true' : 'false'} - aria-describedby={`${usernameId}-error`} + aria-describedby={`${usernameId}-error ${usernameId}-${passwordId}-error`} id={usernameId} /> @@ -153,7 +154,7 @@ export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRoute placeholder={passwordPlaceholder} error={errors.password?.message} aria-invalid={errors.password || errorOnSubmit ? 'true' : 'false'} - aria-describedby={`${passwordId}-error`} + aria-describedby={`${passwordId}-error ${usernameId}-${passwordId}-error`} id={passwordId} /> @@ -177,11 +178,7 @@ export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRoute )} - {errorOnSubmit && ( - - {renderErrorOnSubmit(errorOnSubmit)} - - )} + {errorOnSubmit && {renderErrorOnSubmit(errorOnSubmit)}}