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
a11y: keyboard focus is lost when clicking Table of Contents (TOC) anchor links #8458
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
Ensure all heading elements (h2, h3, etc.) that serve as anchor targets are programmatically focusable (e.g., by ensuring they can receive focus).
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).
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
fix(a11y): preserve keyboard focus when clicking TOC anchor links