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

Aperta Adatta ai principianti
#8,458 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@AnushkaShendge ci sta già lavorando.

Dal 31/10/2026.

  • #8475 di @AnushkaShendge — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, react

Direzione di ricerca

Inizia da src/components/SidebarItem/SidebarItem.jsx e segui il modo in cui il suo NavLink punta agli ID dei titoli; poi verifica come vengono visualizzati i titoli della documentazione e se possono ricevere il focus. Fai in modo che la navigazione del TOC sposti il focus visibile della tastiera sul titolo di destinazione. Il lavoro è completato quando gli utenti che usano la tastiera possono seguire un link del TOC e vedere il focus sulla destinazione; l’issue non indica alcun test, quindi individua il test di accessibilità o del componente pertinente prima di modificare il codice.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
MDX
Stelle
2.3k
Fork
3.4k
Merge medio
22h 59m
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webpack/webpack.js.org

Tutte le issue di webpack/webpack.js.org

Issue simili

Altre issue su Accessibility

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.