From 445ddf05cd9a2265724d3c1dd2a61e348b400856 Mon Sep 17 00:00:00 2001 From: Fahat Adam Date: Sat, 27 Jun 2026 18:22:26 +0100 Subject: [PATCH 1/2] task: fix focus order in create new event form --- app/(dashboard)/events/new/page.test.tsx | 38 +++++ app/(dashboard)/events/new/page.tsx | 162 +++++++++++----------- app/(dashboard)/settings/ACCESSIBILITY.md | 3 +- 3 files changed, 123 insertions(+), 80 deletions(-) create mode 100644 app/(dashboard)/events/new/page.test.tsx diff --git a/app/(dashboard)/events/new/page.test.tsx b/app/(dashboard)/events/new/page.test.tsx new file mode 100644 index 0000000..e097021 --- /dev/null +++ b/app/(dashboard)/events/new/page.test.tsx @@ -0,0 +1,38 @@ +import React from "react" +import { render, screen } from "@testing-library/react" +import userEvent from "@testing-library/user-event" +import NewEventPage from "./page" + +// Mock next/navigation +jest.mock("next/navigation", () => ({ + useRouter() { + return { + push: jest.fn(), + replace: jest.fn(), + prefetch: jest.fn(), + } + }, +})) + +describe("NewEventPage focus order", () => { + it("tabs through fields in the correct visual reading order", async () => { + const user = userEvent.setup() + render() + + // Start tabbing + await user.tab() + expect(screen.getByLabelText(/event title/i)).toHaveFocus() + + await user.tab() + expect(screen.getByLabelText(/description/i)).toHaveFocus() + + await user.tab() + // Select is tricky because Radix UI uses a hidden button. + // Let's just check the id or name if possible, or skip to the next + // The select trigger usually has role="combobox" + expect(screen.getByRole("combobox", { name: /category/i })).toHaveFocus() + + // Add more expectations to see what currently happens + // By keeping this minimal first, we can run it and see the output! + }) +}) diff --git a/app/(dashboard)/events/new/page.tsx b/app/(dashboard)/events/new/page.tsx index 3667fa8..50fbe76 100644 --- a/app/(dashboard)/events/new/page.tsx +++ b/app/(dashboard)/events/new/page.tsx @@ -64,86 +64,20 @@ export default function NewEventPage() {
-
-
- - setTitle(e.target.value)} - required - /> -
- -
- -