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

未關閉 適合新手
#15,392 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
75/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
html, javascript, yaml

研究方向

從 src/project/types/website/website-navigation.ts 中 issue 提到的作用中連結迴圈開始,接著查看相關 issue #9277、#15190 和 #15191 以了解背景。使用提供的 _quarto.yml 和兩個頁面重現問題,然後執行 quarto render 並檢查 _site/get-started.html。完成標準是:與目前頁面完全相符的連結處於作用中狀態,並帶有 aria-current="page";若只在側邊欄中相符,則使用 aria-current="true"。

由索引模型根據 Issue 內容生成。

描述

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
主要語言
JavaScript
星號
6.2k
分支
492
平均合併
15 小時 15 分鐘
30 天內合併 PR
94

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

quarto-dev/quarto-cli 的其他 Issue

查看 quarto-dev/quarto-cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。