diff --git a/frontend/components/forms/LoginForm/LoginForm.tests.tsx b/frontend/components/forms/LoginForm/LoginForm.tests.tsx index b27371c92f..22aabb8443 100644 --- a/frontend/components/forms/LoginForm/LoginForm.tests.tsx +++ b/frontend/components/forms/LoginForm/LoginForm.tests.tsx @@ -140,4 +140,29 @@ describe("LoginForm - component", () => { password, }); }); + it("tabs in the expected order", async () => { + const { user } = renderWithSetup( + + ); + + expect(screen.getByPlaceholderText("Email")).toHaveFocus(); + await user.tab(); + expect(screen.getByPlaceholderText("Password")).toHaveFocus(); + await user.tab(); + expect(screen.getByText("Log in").parentElement).toHaveFocus(); + await user.tab(); + expect( + screen.getByText("Sign in with Test IdP").parentElement + ).toHaveFocus(); + await user.tab(); + expect(screen.getByText("Forgot password?")).toHaveFocus(); + }); }); diff --git a/frontend/components/forms/LoginForm/LoginForm.tsx b/frontend/components/forms/LoginForm/LoginForm.tsx index 957f8fd7ee..566d9cc5eb 100644 --- a/frontend/components/forms/LoginForm/LoginForm.tsx +++ b/frontend/components/forms/LoginForm/LoginForm.tsx @@ -84,28 +84,28 @@ const LoginForm = ({ const showLegendWithImage = () => { let legend = "Single sign-on"; - if (idpName !== "") { + if (idpName) { legend = `Sign in with ${idpName}`; } return ( -
+ <> {idpName} {legend} -
+ ); }; const renderSingleSignOnButton = () => { let legend: string | JSX.Element = "Single sign-on"; - if (idpName !== "") { + if (idpName) { legend = `Sign in with ${idpName}`; } - if (imageURL !== "") { + if (imageURL) { legend = showLegendWithImage(); } @@ -116,8 +116,9 @@ const LoginForm = ({ title="Single sign-on" variant="inverse" onClick={handleSSOSignOn} + tabIndex={0} > -
{legend}
+ {legend} ); }; @@ -183,6 +184,7 @@ const LoginForm = ({ className={`${baseClass}__login-btn`} isLoading={isSubmitting} type="submit" + tabIndex={0} > Log in