diff --git a/apps/web/src/components/files/AttachmentFilePreview.office.browser.test.tsx b/apps/web/src/components/files/AttachmentFilePreview.office.browser.test.tsx index ccb61f86871d9..b1aeb00a1d904 100644 --- a/apps/web/src/components/files/AttachmentFilePreview.office.browser.test.tsx +++ b/apps/web/src/components/files/AttachmentFilePreview.office.browser.test.tsx @@ -1125,6 +1125,7 @@ it.each([ await password.fill("wrong"); await screen.getByRole("button", { name: "Unlock" }).click(); await expect.element(screen.getByText("Incorrect password. Try again.")).toBeVisible(); + await expect.element(password).toHaveFocus(); await password.fill("open me"); await screen.getByRole("button", { name: "Unlock" }).click(); if (kind === "docx") await expect.element(screen.getByText(content)).toBeVisible(); diff --git a/apps/web/src/components/files/FilePasswordPrompt.tsx b/apps/web/src/components/files/FilePasswordPrompt.tsx index c2f7267126e97..cbe09060794ce 100644 --- a/apps/web/src/components/files/FilePasswordPrompt.tsx +++ b/apps/web/src/components/files/FilePasswordPrompt.tsx @@ -35,6 +35,7 @@ export function FilePasswordPrompt(props: { aria-label={gt("File password")} aria-describedby={status} autoComplete="off" + autoFocus={props.incorrect} required /> diff --git a/apps/web/src/components/files/PdfViewer.browser.test.tsx b/apps/web/src/components/files/PdfViewer.browser.test.tsx index ce04a100d8d8f..b1c28756617d2 100644 --- a/apps/web/src/components/files/PdfViewer.browser.test.tsx +++ b/apps/web/src/components/files/PdfViewer.browser.test.tsx @@ -388,9 +388,12 @@ it("retries an incorrect password and renders the encrypted PDF", async () => { container.style.cssText = "display:flex;width:500px;height:400px"; await using screen = await render(, { container }); const password = screen.getByLabelText("File password"); + await expect.element(password).toBeVisible(); + await expect.element(password).not.toHaveFocus(); await password.fill("wrong"); await screen.getByRole("button", { name: "Unlock" }).click(); await expect.element(screen.getByText("Incorrect password. Try again.")).toBeVisible(); + await expect.element(password).toHaveFocus(); await password.fill("open me"); await userEvent.keyboard("{Enter}"); await expect.element(screen.getByText("Unlocked PDF")).toBeVisible();