Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

♿️ Add skip-to-content link and main landmarks (WCAG 2.4.1) (#2501)

Luke Vellad35cab49089c
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index 8124a541e..1ba206f49 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -602,6 +602,7 @@
"signIn": "Sign in",
"signOut": "Sign Out",
"signUp": "Sign Up",
+ "skipToContent": "Skip to main content",
"space": "Space",
"spaceInviteMember": "Invite Member",
"spaceName": "Space Name",
diff --git a/apps/web/src/app/[locale]/(auth)/layout.tsx b/apps/web/src/app/[locale]/(auth)/layout.tsx
index bc0a52498..fa87b8d75 100644
--- a/apps/web/src/app/[locale]/(auth)/layout.tsx
+++ b/apps/web/src/app/[locale]/(auth)/layout.tsx
@@ -14,7 +14,13 @@ export default async function Layout({
<div className="z-10 flex w-full flex-1 lg:p-4">
<div className="flex flex-1 flex-col gap-4 p-6">
<div className="my-auto">
- <div className="mx-auto w-full max-w-sm">{children}</div>
+ <main
+ id="main-content"
+ tabIndex={-1}
+ className="mx-auto w-full max-w-sm"
+ >
+ {children}
+ </main>
</div>
{isQuickCreateEnabled ? (
<div className="flex justify-center lg:hidden">
diff --git a/apps/web/src/app/[locale]/(optional-space)/new/page.tsx b/apps/web/src/app/[locale]/(optional-space)/new/page.tsx
index 2a87f2da8..7ce8b2470 100644
--- a/apps/web/src/app/[locale]/(optional-space)/new/page.tsx
+++ b/apps/web/src/app/[locale]/(optional-space)/new/page.tsx
@@ -45,9 +45,13 @@ export default async function Page() {
</div>
</div>
</div>
- <div className="mx-auto max-w-4xl p-3 sm:px-6 sm:py-5">
+ <main
+ id="main-content"
+ tabIndex={-1}
+ className="mx-auto max-w-4xl p-3 sm:px-6 sm:py-5"
+ >
<CreatePoll />
- </div>
+ </main>
</div>
);
}
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx
index 55230f19d..2e1736612 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx
@@ -76,7 +76,7 @@ export default async function Layout({
<NavUser />
</SidebarFooter>
</Sidebar>
- <SidebarInset className="min-w-0">
+ <SidebarInset id="main-content" tabIndex={-1} className="min-w-0">
<LicenseLimitWarning />
<CustomBrandingPrompt />
<div className="flex flex-1 flex-col">
diff --git a/apps/web/src/app/[locale]/(space)/settings/layout.tsx b/apps/web/src/app/[locale]/(space)/settings/layout.tsx
index 13fbf7af8..8efba27cd 100644
--- a/apps/web/src/app/[locale]/(space)/settings/layout.tsx
+++ b/apps/web/src/app/[locale]/(space)/settings/layout.tsx
@@ -88,7 +88,7 @@ export default async function Layout({
<NavUser />
</SidebarFooter>
</Sidebar>
- <SidebarInset>
+ <SidebarInset id="main-content" tabIndex={-1}>
<div className="flex flex-1 flex-col">
<header className="sticky top-0 z-10 border-b bg-background/90 p-3 backdrop-blur-xs md:hidden">
<div className="flex items-center gap-4">
@@ -103,7 +103,7 @@ export default async function Layout({
</div>
</div>
</header>
- <main className="flex-1 p-4 lg:py-12">{children}</main>
+ <div className="flex-1 p-4 lg:py-12">{children}</div>
</div>
</SidebarInset>
</SidebarProvider>
diff --git a/apps/web/src/app/[locale]/accept-invite/[inviteId]/page.tsx b/apps/web/src/app/[locale]/accept-invite/[inviteId]/page.tsx
index e9473f001..351a53f38 100644
--- a/apps/web/src/app/[locale]/accept-invite/[inviteId]/page.tsx
+++ b/apps/web/src/app/[locale]/accept-invite/[inviteId]/page.tsx
@@ -50,59 +50,61 @@ export default async function JoinPage({
return (
<div className="flex h-dvh flex-col items-center gap-12 py-12">
<Logo />
- <Card className="flex w-full max-w-sm flex-col p-12 text-center">
- <div className="mx-auto mb-4">
- <SpaceIcon
- src={invite.space.image ?? undefined}
- name={invite.space.name}
- size="xl"
- />
- </div>
- <h1 className="font-bold text-base">
- <Trans
- i18nKey="joinSpace"
- defaults="Join {spaceName}"
- values={{
- spaceName: invite.space.name,
- }}
- />
- </h1>
- <p className="mt-1 text-sm">
- <Trans
- i18nKey="acceptInviteTitle"
- defaults="{inviterName} invited you to join {spaceName}"
- values={{
- spaceName: invite.space.name,
- inviterName: invite.invitedBy.name,
- }}
- />
- </p>
- <div className="mt-6">
- <div className="flex flex-col items-center gap-y-2">
- <p className="text-muted-foreground text-sm">
- <Trans
- i18nKey="youAreSignedInAs"
- defaults="You're signed in as"
- />
- </p>
- <div className="flex items-center gap-x-2 rounded-full border p-1 pr-2">
- <OptimizedAvatarImage
- src={user.image}
- name={user.name}
- size="sm"
- />
- <p className="text-sm">{user.email}</p>
+ <main id="main-content" tabIndex={-1} className="w-full max-w-sm">
+ <Card className="flex w-full flex-col p-12 text-center">
+ <div className="mx-auto mb-4">
+ <SpaceIcon
+ src={invite.space.image ?? undefined}
+ name={invite.space.name}
+ size="xl"
+ />
+ </div>
+ <h1 className="font-bold text-base">
+ <Trans
+ i18nKey="joinSpace"
+ defaults="Join {spaceName}"
+ values={{
+ spaceName: invite.space.name,
+ }}
+ />
+ </h1>
+ <p className="mt-1 text-sm">
+ <Trans
+ i18nKey="acceptInviteTitle"
+ defaults="{inviterName} invited you to join {spaceName}"
+ values={{
+ spaceName: invite.space.name,
+ inviterName: invite.invitedBy.name,
+ }}
+ />
+ </p>
+ <div className="mt-6">
+ <div className="flex flex-col items-center gap-y-2">
+ <p className="text-muted-foreground text-sm">
+ <Trans
+ i18nKey="youAreSignedInAs"
+ defaults="You're signed in as"
+ />
+ </p>
+ <div className="flex items-center gap-x-2 rounded-full border p-1 pr-2">
+ <OptimizedAvatarImage
+ src={user.image}
+ name={user.name}
+ size="sm"
+ />
+ <p className="text-sm">{user.email}</p>
+ </div>
</div>
</div>
- </div>
- <div className="mt-6">
- {isWrongAccount ? (
- <SignOutButton />
- ) : (
- <AcceptInviteButton spaceId={invite.spaceId} />
- )}
- </div>
- </Card>
+ <div className="mt-6">
+ {isWrongAccount ? (
+ <SignOutButton />
+ ) : (
+ <AcceptInviteButton spaceId={invite.spaceId} />
+ )}
+ </div>
+ </Card>
+ </main>
</div>
);
}
diff --git a/apps/web/src/app/[locale]/admin-setup/page.tsx b/apps/web/src/app/[locale]/admin-setup/page.tsx
index 6f77de2f8..448490cae 100644
--- a/apps/web/src/app/[locale]/admin-setup/page.tsx
+++ b/apps/web/src/app/[locale]/admin-setup/page.tsx
@@ -29,7 +29,11 @@ export default async function AdminSetupPage() {
}
return (
- <div className="flex h-dvh items-center justify-center">
+ <main
+ id="main-content"
+ tabIndex={-1}
+ className="flex h-dvh items-center justify-center"
+ >
<EmptyState className="h-full">
<EmptyStateIcon>
<CrownIcon />
@@ -50,7 +54,7 @@ export default async function AdminSetupPage() {
<MakeMeAdminButton />
</EmptyStateFooter>
</EmptyState>
- </div>
+ </main>
);
}
diff --git a/apps/web/src/app/[locale]/control-panel/layout.tsx b/apps/web/src/app/[locale]/control-panel/layout.tsx
index 6feab3702..2c5531e3c 100644
--- a/apps/web/src/app/[locale]/control-panel/layout.tsx
+++ b/apps/web/src/app/[locale]/control-panel/layout.tsx
@@ -24,7 +24,7 @@ export default async function AdminLayout({
<ControlPanelSidebarProvider>
<CommandMenu />
<ControlPanelSidebar />
- <SidebarInset>
+ <SidebarInset id="main-content" tabIndex={-1}>
<LicenseLimitWarning />
<div className="flex flex-1 flex-col">
<header className="sticky top-0 z-10 border-b bg-background/90 p-3 backdrop-blur-xs md:hidden">
@@ -40,7 +40,7 @@ export default async function AdminLayout({
</div>
</div>
</header>
- <main className="flex-1 p-4 lg:py-12">{children}</main>
+ <div className="flex-1 p-4 lg:py-12">{children}</div>
</div>
</SidebarInset>
</ControlPanelSidebarProvider>
diff --git a/apps/web/src/app/[locale]/e/[id]/page.tsx b/apps/web/src/app/[locale]/e/[id]/page.tsx
index 9d1db923c..198a430cf 100644
--- a/apps/web/src/app/[locale]/e/[id]/page.tsx
+++ b/apps/web/src/app/[locale]/e/[id]/page.tsx
@@ -125,7 +125,7 @@ export default async function EventPage({
)}
</div>
</header>
- <div className="mx-auto max-w-lg pt-16">
+ <main id="main-content" tabIndex={-1} className="mx-auto max-w-lg pt-16">
<div className="flex flex-col justify-between gap-6 p-4">
<EventHeader>
{isBranded && branding ? (
@@ -233,7 +233,7 @@ export default async function EventPage({
</EventSection>
) : null}
</div>
- </div>
+ </main>
</div>
);
}
diff --git a/apps/web/src/app/[locale]/globals.css b/apps/web/src/app/[locale]/globals.css
index c6fa7dc55..e1431f3ca 100644
--- a/apps/web/src/app/[locale]/globals.css
+++ b/apps/web/src/app/[locale]/globals.css
@@ -2,3 +2,12 @@
@import "@rallly/tailwind-config";
/* Any app specific overrides will go here */
+
+/*
+ * The skip-to-content link moves focus to the page's #main-content landmark.
+ * The link itself is the visible focus indicator, so suppress the outline on
+ * the landmark to avoid drawing a box around the entire content region.
+ */
+#main-content:focus {
+ outline: none;
+}
diff --git a/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
index 551c4592d..4cc00ee0b 100644
--- a/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
+++ b/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
@@ -48,7 +48,11 @@ const GoToApp = () => {
export function InvitePage() {
return (
<div className="page-bg-gray-100 h-dvh overflow-auto p-3 lg:p-6 dark:bg-gray-900">
- <div className="mx-auto w-full max-w-4xl space-y-3">
+ <main
+ id="main-content"
+ tabIndex={-1}
+ className="mx-auto w-full max-w-4xl space-y-3"
+ >
<GoToApp />
<EventCard />
<VotingForm>
@@ -56,7 +60,7 @@ export function InvitePage() {
</VotingForm>
<Discussion />
<PollFooter />
- </div>
+ </main>
</div>
);
}
diff --git a/apps/web/src/app/[locale]/layout.tsx b/apps/web/src/app/[locale]/layout.tsx
index a07c3234f..1e7064161 100644
--- a/apps/web/src/app/[locale]/layout.tsx
+++ b/apps/web/src/app/[locale]/layout.tsx
@@ -9,6 +9,7 @@ import { Inter } from "next/font/google";
import { notFound } from "next/navigation";
import type React from "react";
import type { Params } from "@/app/[locale]/types";
+import { SkipNavLink } from "@/components/skip-nav-link";
import { BrandingProvider } from "@/features/branding/client";
import { getInstanceBrandingConfig } from "@/features/branding/queries";
import { ThemeProvider } from "@/features/theme/client";
@@ -78,6 +79,7 @@ export default async function Root({
<I18nProvider locale={locale} resources={resources}>
<TRPCProvider>
<LazyMotion features={domAnimation}>
+ <SkipNavLink />
<PostHogPageView />
<TooltipProvider>{children}</TooltipProvider>
</LazyMotion>
diff --git a/apps/web/src/app/[locale]/quick-create/page.tsx b/apps/web/src/app/[locale]/quick-create/page.tsx
index 70c66ea31..0efd870b2 100644
--- a/apps/web/src/app/[locale]/quick-create/page.tsx
+++ b/apps/web/src/app/[locale]/quick-create/page.tsx
@@ -18,7 +18,7 @@ export default async function QuickCreatePage() {
const { t } = await getTranslation();
return (
- <div className="flex h-dvh p-2">
+ <main id="main-content" tabIndex={-1} className="flex h-dvh p-2">
<Card className="flex flex-1 flex-col gap-6 p-6">
<div className="mx-auto w-full max-w-md flex-1">
<div className="space-y-8">
@@ -39,7 +39,7 @@ export default async function QuickCreatePage() {
</Link>
</div>
</Card>
- </div>
+ </main>
);
}
diff --git a/apps/web/src/app/[locale]/setup/page.tsx b/apps/web/src/app/[locale]/setup/page.tsx
index fb2796cc3..da16b6d68 100644
--- a/apps/web/src/app/[locale]/setup/page.tsx
+++ b/apps/web/src/app/[locale]/setup/page.tsx
@@ -17,7 +17,7 @@ export default async function SetupPage() {
return (
<div className="flex min-h-dvh justify-center bg-background p-4 sm:items-center">
- <div className="w-full max-w-sm">
+ <main id="main-content" tabIndex={-1} className="w-full max-w-sm">
<article className="space-y-8">
<div className="flex justify-center py-8">
<Logo />
@@ -33,11 +33,11 @@ export default async function SetupPage() {
/>
</p>
</header>
- <main>
+ <div>
<CreateSpaceForm />
- </main>
+ </div>
</article>
- </div>
+ </main>
</div>
);
}
diff --git a/apps/web/src/components/error-page.tsx b/apps/web/src/components/error-page.tsx
index 472c06576..41cd49e49 100644
--- a/apps/web/src/components/error-page.tsx
+++ b/apps/web/src/components/error-page.tsx
@@ -19,7 +19,11 @@ export function ErrorPage({
}) {
return (
<div className="page-bg-gray-100">
- <main className="mx-auto w-full max-w-7xl px-6 pt-10 pb-16 sm:pb-24 lg:px-8">
+ <main
+ id="main-content"
+ tabIndex={-1}
+ className="mx-auto w-full max-w-7xl px-6 pt-10 pb-16 sm:pb-24 lg:px-8"
+ >
<Image
src="/static/logo.svg"
alt="Rallly"
diff --git a/apps/web/src/components/layouts/poll-layout.tsx b/apps/web/src/components/layouts/poll-layout.tsx
index da86cf0c9..b44562158 100644
--- a/apps/web/src/components/layouts/poll-layout.tsx
+++ b/apps/web/src/components/layouts/poll-layout.tsx
@@ -71,9 +71,9 @@ const Layout = ({ children }: React.PropsWithChildren) => {
</div>
</div>
</div>
- <div className="p-3">
+ <main id="main-content" tabIndex={-1} className="p-3">
<div className="mx-auto max-w-4xl space-y-3">{children}</div>
- </div>
+ </main>
</div>
);
};
diff --git a/apps/web/src/components/skip-nav-link.tsx b/apps/web/src/components/skip-nav-link.tsx
new file mode 100644
index 000000000..7809f46cf
--- /dev/null
+++ b/apps/web/src/components/skip-nav-link.tsx
@@ -0,0 +1,14 @@
+"use client";
+
+import { Trans } from "@/i18n/client";
+
+export function SkipNavLink() {
+ return (
+ <a
+ href="#main-content"
+ className="sr-only rounded-md bg-background font-medium text-foreground text-sm shadow-md ring-2 ring-ring focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-100 focus:px-4 focus:py-2"
+ >
+ <Trans i18nKey="skipToContent" defaults="Skip to main content" />
+ </a>
+ );
+}