Skip to content

chrome(nav): desktop hash-anchor click does not move focus to the section #119

@yigitdot

Description

@yigitdot

Follow-up from the PR #118 review.

Background

components/site/Chrome.tsx handleNavClick intercepts same-page /#section clicks and does history.replaceState + el.scrollIntoView(). Unlike a real anchor navigation, this does not move keyboard / screen-reader focus to (or near) the target section — so after a nav click, tab order and the SR reading position stay at the nav.

This is a pre-existing weakness (the native pre-fix <Link> behavior was already weak here under output: "export"), not a regression introduced by #118. Tracked separately so #118 stays scoped to the hash-accumulation fix.

Suggested change

In the same-page branch of handleNavClick, after the scroll:

el.setAttribute("tabindex", "-1");
el.focus({ preventScroll: true });

(preventScroll so it doesn't fight the smooth scrollIntoView.) Apply the same to MobileMenu's anchor path for parity if it has the same gap. Verify with keyboard-only + VoiceOver that focus lands in the target section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions