Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/web/e2e/unified-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,15 @@ test("a phone scrolls wide tables inside their frames and keeps every Settings t
await expect(page.getByRole("table", { name: "Startup settings" }).getByRole("columnheader", { name: "Restarts", exact: true })).toBeInViewport({ ratio: 1 });
expect(await pageScrollsSideways()).toBe(false);
});

test("skip to content moves focus to the page and keeps its route", async ({ page, request }) => {
await openConsole(page, request, "settings?id=storage");
const current = page.getByRole("navigation").getByRole("button", { name: "Workspace storage", exact: true });
await expect(current).toHaveAttribute("aria-current", "page");
await page.keyboard.press("Tab");
await expect(page.getByRole("link", { name: "Skip to main content" })).toBeFocused();
await page.keyboard.press("Enter");
await expect(page.locator("#main-content")).toBeFocused();
await expect(current).toHaveAttribute("aria-current", "page");
expect(new URL(page.url()).hash).toBe("#settings?id=storage");
});
6 changes: 5 additions & 1 deletion apps/web/src/ConsoleApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function ConsoleShell() {
<ConsoleNavigationContext.Provider value={navigation}>
<ConsoleTourContext.Provider value={openTour}>
<div className="app-shell">
<a className="skip-link" href="#main-content">{t("skipToContent")}</a>
{/* The router owns the URL fragment, so the link moves focus instead of navigating. */}
<a className="skip-link" href="#main-content" onClick={(event) => {
event.preventDefault();
document.getElementById("main-content")?.focus();
}}>{t("skipToContent")}</a>
<ConsoleSidebar active={consoleNavParent(location.view)} onSelect={(view) => navigate(view)} onIntent={prefetch} onGettingStarted={() => navigate("overview", {}, "getting-started")} />
<main className="app-main" id="main-content" tabIndex={-1}>
<div className="page-transition" key={`${location.view}:${location.params.project ?? ""}:${location.params.id ?? ""}`}>
Expand Down
Loading