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 摘要。