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

Offen Anfängerfreundlich
#15,392 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
75/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
html, javascript, yaml

Rechercherichtung

Beginne in src/project/types/website/website-navigation.ts bei der im Issue genannten Schleife für aktive Links und sieh dir dann die verwandten Issues #9277, #15190 und #15191 als Kontext an. Reproduziere das Problem mit der bereitgestellten _quarto.yml und zwei Seiten, führe dann quarto render aus und prüfe _site/get-started.html. Fertig ist es, wenn der genaue Link zur aktuellen Seite aktiv ist und aria-current="page" hat; bei einer Übereinstimmung nur in der Seitenleiste wird aria-current="true" verwendet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
JavaScript
Sterne
6.2k
Forks
492
Ø Merge
15 Std. 15 Min.
Gemergte PRs (30 T.)
94

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus quarto-dev/quarto-cli

Alle Issues in quarto-dev/quarto-cli

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.