Keyboard focus does not follow #hash links (e.g. "skip to content") · Issue #787 · unpoly/unpoly · GitHub
Skip to content

Keyboard focus does not follow #hash links (e.g. "skip to content") #787

Closed

Description

@johndwells

Bug description

When activating a href="#target" “Skip to content” link, Unpoly 3.11+ scrolls to the target but does not move keyboard focus to that element. This breaks the native browser behavior and makes skip links inaccessible.

Before Unpoly 3.11 (before full hash-link handling), the browser would:

  1. Move focus to the anchor target
  2. Scroll that element into view

With Unpoly intercepting hash links, Unpoly scrolls but suppresses or overrides the focus change.

As a result, the user visually lands on the main content, but keyboard focus remains at the top of the document. Pressing Tab then moves focus back to header links instead of continuing from the main content.

This is a regression in native accessibility behavior.

Using up-follow="false" does not prevent Unpoly from handling the anchor link.


Reproduction project

StackBlitz (minimal demo):
https://stackblitz.com/edit/unpoly-keyboard-focus-does-not-follow-hash-links?file=index.html

The demo uses the standard WCAG skip-link pattern:

<div id="main-content" tabindex="-1">

Steps to reproduce the behavior

  1. Open the reproduction project linked above.
  2. Resize the browser so the “Main content” section is below the fold.
  3. Press Tab until the “Skip to content” link receives focus.
  4. Press Enter to activate it.
  5. Observe:
    • The page scrolls to the correct location.
    • Keyboard focus does not move to #main-content.
  6. Press Tab again.
  7. Focus returns to the header navigation links instead of moving to the CTA button inside the main content area.

Expected behavior

Activating an anchor link such as href="#main-content" should:

  1. Move keyboard focus to the target element (with tabindex="-1"), and
  2. Scroll it into view as a result of receiving focus.

This is the normal browser behavior and is required for WCAG-compliant skip links.

Activity

  1. triskweline commented on Jan 18, 2026

    @triskweline
    Contributor

    Fixed in 3.13.0-rc4.

  2. added a commit that references this issue on Mar 20, 2026
    a43d7b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions