Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: preserve verification input tab order

Amruth Pillai5632477ca53c
diff --git a/apps/web/src/components/layout/navigation-focus.test.tsx b/apps/web/src/components/layout/navigation-focus.test.tsx
index 1c976ed86..da383ec53 100644
--- a/apps/web/src/components/layout/navigation-focus.test.tsx
+++ b/apps/web/src/components/layout/navigation-focus.test.tsx
@@ -164,8 +164,11 @@ it("focuses the primary verification field instead of its heading", async () =>
await waitFor(() => expect(screen.getByRole("heading", { name: "Ordinary" })).toHaveFocus());
await act(() => router.navigate({ to: "/code" }));
await waitFor(() => expect(screen.getByRole("textbox", { name: "Code" })).toHaveFocus());
+ expect(screen.getByRole("textbox", { name: "Code" })).toHaveProperty("tabIndex", 0);
await act(() => router.navigate({ to: "/backup" }));
await waitFor(() => expect(screen.getByRole("textbox", { name: "Backup code" })).toHaveFocus());
+ expect(screen.getByRole("textbox", { name: "Backup code" })).toHaveProperty("tabIndex", 0);
await act(() => router.navigate({ to: "/ordinary" }));
await waitFor(() => expect(screen.getByRole("heading", { name: "Ordinary" })).toHaveFocus());
+ expect(screen.getByRole("heading", { name: "Ordinary" })).toHaveAttribute("tabindex", "-1");
});
diff --git a/apps/web/src/components/layout/navigation-focus.tsx b/apps/web/src/components/layout/navigation-focus.tsx
index ef67aafb6..3ca41c78b 100644
--- a/apps/web/src/components/layout/navigation-focus.tsx
+++ b/apps/web/src/components/layout/navigation-focus.tsx
@@ -18,7 +18,7 @@ export function NavigationFocus() {
document.querySelector<HTMLElement>("main h1, h1") ??
document.querySelector<HTMLElement>("main, #main-content");
if (!target) return;
- if (!target.hasAttribute("tabindex")) target.tabIndex = -1;
+ if (!target.hasAttribute("tabindex") && target.tabIndex < 0) target.tabIndex = -1;
target.focus({ preventScroll: true });
});
return () => cancelAnimationFrame(frame);
diff --git a/tests/e2e/specs/two-factor-focus.spec.ts b/tests/e2e/specs/two-factor-focus.spec.ts
index 002ec6d20..2da61c63e 100644
--- a/tests/e2e/specs/two-factor-focus.spec.ts
+++ b/tests/e2e/specs/two-factor-focus.spec.ts
@@ -74,6 +74,10 @@ test("two-step and backup verification receive typing after sign-in navigation",
await expect(backup).toBeVisible();
await routeFocusSettled(page);
await expect(backup).toBeFocused();
+ await page.keyboard.press("Tab");
+ await expect(page.getByRole("checkbox")).toBeFocused();
+ await page.keyboard.press("Shift+Tab");
+ await expect(backup).toBeFocused();
await page.screenshot({ path: info.outputPath("backup-code-page.png"), animations: "disabled" });
await page.keyboard.type(backupCode.toLowerCase().replaceAll("-", ""));
await page.getByRole("button", { name: "Verify", exact: true }).click();