Skip to content

fix(layout): a client-side navigation announces nothing and moves no focus #70

Closed

Description

@sydevs-bot

Summary

Vike Client Routing swaps the page under <main> while the chrome persists, and nothing tells the visitor it happened: focus is never moved and the new title is never announced. The two hooks that are the natural home for the fix — pages/+onPageTransitionStart.ts and pages/+onPageTransitionEnd.ts — currently do nothing but write four console.log lines per navigation and toggle a page-transition body class that no stylesheet in the repo uses.

Raised by the Wednesday analysis survey (ISO week 36, angle: accessibility).

What the visitor actually experiences

Where the link was What happens to focus
In the header (persists across the swap) Focus stays on that link. Tabbing forward walks the rest of the nav, not the new content
In the page body — a ContentCard, a TableOfContents entry, a breadcrumb The element is removed, so focus falls back to <body>. The next Tab starts from the top of the document

In both cases document.title changes silently. A screen-reader user gets no signal at all that the page changed.

The announcement half is a WCAG 2.1 4.1.3 Status Messages (AA) gap, which docs/rules/design-system.md makes non-optional. The focus half is not a numbered failure on its own — it is the standard remedy that makes the announcement useful.

Approach

  1. layouts/LayoutRoot.tsx — render one persistent polite announcer beside the Sentry boundary, so bare embed routes get it too:
    <div aria-live="polite" aria-atomic="true" className="sr-only" id="route-announcer" />
  2. layouts/LayoutChrome.tsx:139 and layouts/LayoutMap.tsx:57 — give each <main> id="main-content" and tabIndex={-1} so it can receive programmatic focus without entering the tab order.
  3. pages/+onPageTransitionEnd.ts — write document.title into #route-announcer, then document.getElementById('main-content')?.focus({ preventScroll: true }). Skip the focus move when pageContext.isBackwardNavigation is true: back/forward should restore the previous scroll position, not steal focus. Keep announcing in that case.
  4. Both hooks — delete the four console.log calls. Either style .page-transition or drop the class; right now it is added and removed for nothing.

Acceptance criteria

  • After an in-site navigation, focus is on <main> and the next Tab enters the new page's content.
  • After an in-site navigation, a polite live region carries the new document.title.
  • A back/forward navigation announces but does not move focus, and scroll position is unchanged from today's behaviour.
  • No console.log remains in either transition hook.
  • page-transition is either styled or removed — it is not added to the DOM unused.

Verification checklist

  • pnpm dev, then from / click a header nav link and a ContentCard link in turn; after each, press Tab once and confirm the focused element is inside the new page rather than in the header.
  • With VoiceOver (or NVDA) running, perform the same two navigations and confirm the new page title is spoken each time.
  • Navigate forward twice, then press Back; confirm the title is spoken and the scroll position is restored.
  • grep -rn "console.log" pages/+onPageTransition*.ts returns nothing.
  • pnpm lint && pnpm typecheck && pnpm test:run pass.

Notes

  • Not a duplicate: search_issues over repo:sydevs/WeMeditateWeb for accessibility and for page transition focus management client-side navigation announce route change returns nothing open (the only hit, feat(preview): block link navigation in live-preview routes #46, is closed and about blocking navigation in preview routes).
  • Evidence that the class is dead: grep -rn "page-transition" . (excluding node_modules and .git) matches only the two hook files; the repo's four stylesheets are components/organisms/SubtleSystem/SubtleSystem.css, layouts/style.css, layouts/tailwind.css, layouts/fonts.css.
  • Optional, same two lines of change: once <main> has an id, a skip link in LayoutChrome is a one-line addition. It is not a 2.4.1 conformance failure today — the page has <header>/<nav>/<main>/<footer> landmarks, which W3C technique ARIA11 accepts as sufficient — but it is the cheap win for keyboard users who have to pass the same header nav on every page. Fold it in or leave it; say which.

🤖 Written by the sydevs autonomous loop — see what this is

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Hold Until

None yet

Priority

Medium

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions