Navbar marks the wrong item as the current page when two items link into the same sidebar

Đang mở Phù hợp với người mới
#15,392 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

Chưa có ai nhận issue này.

Đá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
75/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ệ
html, javascript, yaml
Lĩnh vực
accessibility, web-dev

Hướng nghiên cứu

Bắt đầu tại src/project/types/website/website-navigation.ts, ở vòng lặp liên kết đang hoạt động được đề cập trong issue, sau đó xem các issue liên quan #9277, #15190 và #15191 để biết thêm ngữ cảnh. Tái hiện bằng _quarto.yml được cung cấp và hai trang, rồi chạy quarto render và kiểm tra _site/get-started.html. Hoàn tất khi liên kết khớp chính xác với trang hiện tại đang hoạt động và có aria-current="page"; nếu chỉ khớp trong thanh bên thì dùng aria-current="true".

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

Mô tả

accessibility bug website-navigation websites
I have:
  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide
Bug description

In a website with a navbar and a sidebar, the navbar marks the first item whose page is in the current sidebar as active, even when a later item links to the current page.
That item also gets aria-current="page", so a screen reader announces the wrong page as current.

The loop that latches the active link breaks on the first navbar link whose href appears anywhere in the sidebar of the current page, before it checks for an exact match:
https://github.com/quarto-dev/quarto-cli/blob/1d80652ba64516c46173120048892c6694be9fb6/src/project/types/website/website-navigation.ts#L558-L576

When "Home" and "Get started" both link to pages of the same sidebar, "Home" wins on every page of that sidebar.
Issue #9277 reports the same loop picking "Home" when the sidebar has a logo.

Related: #9277, #15190, #15191.

Steps to reproduce

_quarto.yml:

project:
  type: website
website:
  title: "Repro"
  navbar:
    left:
      - href: index.qmd
        text: Home
      - href: get-started.qmd
        text: Get started
  sidebar:
    style: docked
    contents:
      - index.qmd
      - get-started.qmd
format: html

index.qmd:

---
title: Home
---

Home.

get-started.qmd:

---
title: Get started
---

Get started.

Run quarto render, then open _site/get-started.html.

Actual behavior

On get-started.html, the navbar renders:

<a class="nav-link active" href="./index.html" aria-current="page">
<a class="nav-link" href="./get-started.html">
Expected behavior

The link to the current page is active and has aria-current="page":

<a class="nav-link" href="./index.html">
<a class="nav-link active" href="./get-started.html" aria-current="page">

An exact match should win over a sidebar match.
When only a sidebar match exists, the link marks a section, not the page, so aria-current="true" fits better than "page".

Your environment
  • IDE: none, command line.
  • OS: macOS 27.2.
Quarto check output
Quarto 99.9.9
[✓] Checking environment information...
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.13.0: OK
      Dart Sass version 1.107.1: OK
      Deno version 2.9.8: OK
      Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: 1d80652ba64516c46173120048892c6694be9fb6
Ngôn ngữ chính
JavaScript
Star
6.2k
Fork
492
Merge trung bình
15 giờ 15 phút
Pull request đã merge (30 ngày)
94

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 quarto-dev/quarto-cli

Tất cả issue của quarto-dev/quarto-cli

Issue tương tự

Thêm issue về JavaScript

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.