You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(nav): move focus into the section after a cross-route nav tap #274
A section link tapped on the same page moves keyboard and screen-reader focus into that section. A section link tapped from another route (/blog/*, /legal/*) does not. Since #273, the mobile drawer soft-navs to /#id with router.push and focus goes back to the hamburger toggle. The desktop nav (Chrome.tsx, since #270) falls through to the native <Link>, and focus stays wherever it was. In both cases the viewport lands on the section, but the next Tab starts from the top of the nav instead of from inside the section.
Next's own hash scroll calls domNode.focus() (layout-router.js). That call does nothing here, because sections have no tabindex.
Evidence
Headless Chrome at 375×812 against the static export, drawer tap from /blog/ → method: location is /#method and the section is at the top of the viewport, but document.activeElement is .mm-toggle. The same tap on / focuses #method.
Before #273 the full reload reset focus to the document. That was also wrong, just less visibly so.
Proposed change
Drawer (components/site/MobileMenu.tsx): when the drawer closes on a link to a section on another route, set focusMovedToSectionRef so the toggle-refocus effect doesn't grab focus. Keep the pending id. Once the route has committed (e.g. a usePathname() effect, or a check that the element now exists), focus the section the same way the same-page path does: add tabindex="-1" only if the element isn't already focusable, and pass preventScroll: true so the focus doesn't fight the router's scroll.
Desktop nav (components/site/Chrome.tsx): same gap. Consider one shared helper, so both navs focus the target after a cross-route arrival with the same rule.
Acceptance
From /blog/, a blog post and /legal/privacy/, at mobile width (drawer) and desktop width (nav): tapping a section leaves document.activeElement on that section, and the next Tab reaches the first focusable element inside it.
Scroll position and URL are unchanged from the current behaviour: one clean hash, section at the viewport top, no jump caused by the focus.
home from another route still lands on / with focus on the toggle or nav, not on #intro.
Activity