Skip to content

a11y: keyboard focus is lost when clicking Table of Contents (TOC) anchor links #8458

Open

Description

@dishu305

Issue Type

  • Accessibility (a11y) Improvement
  • Typo / Grammar Error
  • Outdated Code Example
  • Other

Location

Component: src/components/SidebarItem/SidebarItem.jsx (Table of Contents anchor links)
Affected Pages: All documentation pages with a sidebar TOC (e.g., https://webpack.js.org/concepts/)

Description

When a keyboard or screen-reader user clicks a Table of Contents (TOC) anchor link in the sidebar, the page scrolls to the correct heading, but keyboard focus is lost. It either remains on the sidebar link or resets, making it confusing for assistive-technology users to know where they are on the page after navigation.

Proposed Solution

  1. Ensure all heading elements (h2, h3, etc.) that serve as anchor targets are programmatically focusable (e.g., by ensuring they can receive focus).
  2. Modify the NavLink in src/components/SidebarItem/SidebarItem.jsx to include an onClick handler that:
    • Prevents default behavior if necessary.
    • Finds the target heading element by its ID.
    • Calls .focus() on the target element after a brief timeout (to allow the scroll animation to complete).
  3. Ensure the default browser focus outline is visible for these headings.

Why this is a good first issue

This is a localized, self-contained fix within a single React component (SidebarItem.jsx). It does not require broad architectural changes.

I would love to implement this fix and submit a PR if the maintainers agree with this scope.

Activity

  1. added a commit that references this issue on Oct 26, 2026
    0795396
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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions