-
Notifications
You must be signed in to change notification settings - Fork 0
feat(a11y): set page titles and move focus to main on navigation #113
Conversation
Keyboard users had to tab through the whole header on every page. A
"Skip to main content" link is now the first tab stop: hidden until
focused, then shown top left in white on the dark text colour. It moves
focus to <main id="main-content" tabIndex={-1}> without adding a hash
to the URL. Browser test covers focus order, visibility, colours and the
focus move.
Closes #102
Every page now sets a document title ("My Cookbook – Recipe Platform",
the recipe's name on detail pages). When the pathname changes, AppShell
scrolls to the top and moves focus to main, as a full page load would, so
screen readers start on the new page. Not on first load, not for query
string changes (search, filters, paging) and not while a dialog is open.
Closes #103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No merge blockers found, but a few issues worth addressing:
- Back/Forward navigation (
AppShell.tsx:23): Scrolling to the top on every pathname change prevents users from returning to their previous scroll position. Consider preserving scroll restoration for browser history navigation. - Protected routes (
CookbookPage.tsx:48): If session restoration fails, the page title can remain from the previous route. Consider setting a title for the authentication error state. - Recipe editing (
RecipeCreatePage.tsx:877): Unavailable or unauthorized recipes still display "Edit recipe" in the browser tab. The title should reflect the actual error state.
Addressing them would improve navigation consistency and accessibility.
…or states
- AppShell no longer scrolls to the top on Back/Forward (POP), so the
browser's restored position is kept; focus still moves to main.
- RequireAuth titles its own states ("Restoring session", "Session could
not be restored"), so a protected page that cannot render no longer
keeps the previous page's title.
- The edit page titles each state: "Recipe could not be loaded",
"Recipe unavailable", "Cannot edit recipe"; "Edit <title>" only when
editing. A PageTitle component sets titles from such branches, since a
parent's unconditional usePageTitle would override the child page's.
|
Thanks for the approval. All three follow-ups are done in the latest commit:
These titles are set through a small
Heads-up: #112 and #116 also touch focus and scroll handling (#112 adds |
…les-focus # Conflicts: # apps/web/src/components/shell/AppShell/AppShell.tsx # apps/web/src/features/recipes/RecipeCreatePage.test.tsx
|
Merge-order note, to replace my earlier "small rebase" heads-up: this branch contains #112's original skip-link commit (025f1ff), which is still under a change request there; the I've merged the latest |
…les-focus # Conflicts: # apps/web/src/components/shell/AppShell/AppShell.css # e2e/smoke.spec.ts
Changes
usePageTitle()hook; every route sets the tab title, e.g. "Explore recipes – Recipe Platform", "My Cookbook – …", the recipe's own name on detail pages, "Recipe not found", "Edit title", "Page not found". Previously every page was just "Recipe Platform".AppShellscrolls to the top and moves focus tomain, as a full page load would, so screen readers start on the new page instead of the link that was activated. Focus is not moved:h1, because lazily loaded pages (feat(perf): cut initial JavaScript for Explore by about a third #93) render their heading only after their code arrives.Validation
npm run checkpasses (211 unit tests).mainafter opening a recipe.AI usage
Written with Claude Code (Anthropic) to address a teammate's review of the final-delivery findings. Please review the diff as you would any other contribution.
Closes #103