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

Đang mở Phù hợp với người mới
#8,458 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@AnushkaShendge đang làm issue này rồi.

Từ ngày 31/10/2026.

  • #8475 của @AnushkaShendge — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, react

Hướng nghiên cứu

Bắt đầu với src/components/SidebarItem/SidebarItem.jsx và theo dõi cách NavLink của nó trỏ đến các ID tiêu đề; sau đó kiểm tra cách các tiêu đề tài liệu được kết xuất và liệu chúng có thể nhận tiêu điểm hay không. Điều chỉnh để thao tác điều hướng TOC đặt tiêu điểm bàn phím hiển thị lên tiêu đề đích. Công việc hoàn tất khi người dùng bàn phím có thể đi theo liên kết TOC và thấy tiêu điểm ở đích; issue không nêu bài kiểm thử nào, vì vậy hãy xác định bài kiểm thử accessibility hoặc component phù hợp trước khi thay đổi mã.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
MDX
Star
2.3k
Fork
3.4k
Merge trung bình
22 giờ 59 phút
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của webpack/webpack.js.org

Tất cả issue của webpack/webpack.js.org

Issue tương tự

Thêm issue về Accessibility

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.