Skip to content

Commit

Permalink
fix: fix error alert focus on login and registration form (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque authored Jul 4, 2024
1 parent 5bbaba6 commit d63699b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/forms/login-popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ const LoginForm = () => {
if (loginErrorCode === NUDGE_PASSWORD_CHANGE || loginErrorCode === REQUIRE_PASSWORD_CHANGE) {
dispatch(setCurrentOpenedForm(FORGOT_PASSWORD_FORM));
}
if (errorAlertRef.current) {
errorAlertRef.current.focus();
}
}
}, [dispatch, loginErrorCode, loginErrorContext]);

Expand Down Expand Up @@ -234,7 +237,7 @@ const LoginForm = () => {
</div>
</>
)}
<div ref={errorAlertRef}>
<div ref={errorAlertRef} tabIndex="-1" aria-live="assertive">
<LoginFailureAlert
errorCode={errorCode.type}
context={errorCode.context}
Expand Down
5 changes: 4 additions & 1 deletion src/forms/registration-popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ const RegistrationForm = () => {
if (registrationErrorCode) {
setErrorCode(prevState => ({ type: registrationErrorCode, count: prevState.count + 1 }));
moveScrollToTop(registerErrorAlertRef);
if (registerErrorAlertRef.current) {
registerErrorAlertRef.current.focus();
}
}
}, [registrationErrorCode]);

Expand Down Expand Up @@ -312,7 +315,7 @@ const RegistrationForm = () => {
currentProvider={currentProvider}
referrer={REGISTRATION_FORM}
/>
<div ref={registerErrorAlertRef}>
<div ref={registerErrorAlertRef} tabIndex="-1" aria-live="assertive">
<RegistrationFailureAlert
errorCode={errorCode.type}
failureCount={errorCode.count}
Expand Down

0 comments on commit d63699b

Please sign in to comment.