Listing category filter and URL hash disagree after Back, or with `&`, `=` or `%` in a category

未关闭 适合新手
#15,340 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
frontend

调研方向

从 quarto-listing.js 开始,重点查看 applyListingHash、makeHash 和 parseHash,然后使用提供的类别名称,在渲染后的列表中复现这三个情况。检查返回原始 URL 时筛选器如何重置,以及编码后的类别名称如何在重新加载后保留。完成标准是:在原始 URL 下,所有条目都出现且没有选中任何类别;每个含特殊字符的类别都能选中并显示对应条目,且控制台没有错误。

由索引模型根据 Issue 内容生成。

描述

bug listings
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

The category filter of a listing can disagree with the #category= hash in the URL.

applyListingHash in quarto-listing.js returns early when there is no hash, and it only filters when the category is not empty, so Back to the bare URL or to #category= never shows all items again.

Category names with &, = or % break after a reload or a shared link.
makeHash writes the name without encoding, parseHash splits on & and =, and the value is decoded twice: once in parseHash and again in applyListingHash.
So R&D is read as R, and 100% throws URIError: URI malformed in window["quarto-listing-loaded"], before pagination and progressive images are wired.

With #15339, item category tags become links, so a Ctrl or middle click on a tag opens such a URL in a new tab.

Related: #11752, #10829, #15339.

Steps to reproduce

_quarto.yml:

project:
  type: website
website:
  title: "Listing"

index.qmd:

---
title: "Posts"
listing:
  contents: posts
  categories: true
---

posts/one.qmd:

---
title: "Post one"
date: 2026-01-01
categories: [alpha, "R&D"]
---

Text.

posts/two.qmd:

---
title: "Post two"
date: 2026-01-02
categories: [beta, "100%"]
---

Text.

Render the website and open _site/index.html.

  1. Click "alpha" in the categories filter, then press Back.
  2. Click "R&D", then reload the page.
  3. Click "100%", then reload the page.
Actual behavior
  1. The URL has no hash, but the listing still shows one item and "alpha" is still active.
  2. The URL is #category=R&D, the listing shows no items, and no entry is active.
  3. The URL is #category=100%, the console shows URIError: URI malformed, both items show, and no entry is active.
Expected behavior
  1. Back to the bare URL shows all items, with no category active ("All" is active in the numbered style).
  2. After a reload, the listing shows the one "R&D" item, and "R&D" is active.
  3. After a reload, the listing shows the one "100%" item, "100%" is active, and the console has no error.
Your environment
  • Quarto built from main (ac310a424). The listing script is main's quarto-listing.js.
  • Browser: Brave (Chromium) on macOS 27.2.
Quarto check output
Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/mcanouil/Library/Caches/quarto
      Project: none found (single-file mode)
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.10.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
      Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin
[✓] Checking basic markdown render....OK
主要语言
JavaScript
星标
6.2k
派生
482
平均合并
17 小时 46 分钟
30 天内合并 PR
135

环境准备

从这里开始

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