Repository navigation
Fix website listings stacking update handlers on hash change - #15214
Merged
Merged
Conversation
quarto-listing-loaded both applied the URL hash and attached list.on("updated")
to every listing registered so far. Each listing's inline script called it on
DOMContentLoaded and again from its own window hashchange listener, so the
first of two listings started with two handlers and every hash change added
one handler per listing on the page to each listing.
The hashchange listener was added in 962d83d for #1139 and only needs the
hash part; back/forward between categories relies on it too. Wiring is now
guarded per listing id, and a single hashchange listener in quarto-listing.js
only applies the hash.
Fixes #15206
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
2 of 5 tasks
cderv
added a commit
that referenced
this pull request
Oct 28, 2026
A click on a page link in a website listing ran list.update() twice, so every "updated" handler ran twice per click. Quarto's link onclick called showPage() on top of list.js's own pagination click listener, which also shows the page. The onclick now only records the page in the URL hash and leaves showing the page to list.js. See #15214
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Website listings attached another
list.on("updated")handler on every URL hash change, and a page with several listings started with extra ones, so a single listing update reran the same work several times. Found while reviewing #9469, details in #15206.Fix
window["quarto-listing-loaded"]now wires each listing once, keyed by its id, and the hash handling moved to its ownapplyListingHash(). Thehashchangelistener emitted for each listing inwebsite-listing-template.tsis replaced by a single one inquarto-listing.jsthat only applies the hash. That listener came from 962d83d for #1139, and back/forward between categories still relies on it.applyListingHash()returns early when no listing is registered yet, as the single listener is now attached before any listing script runs.Tests
listing-interactions.spec.tspins the current category, page hash, back/forward, progressive image and no-matching behavior on a page with two paginated listings. It passes before and after the fix.listing-update-handlers.spec.tscounts handler runs for onelist.update(). Before the fix, the first listing ran it 2 times after load, and the two listings 8 and 7 times after three hash changes. It is now 1 in every case.Fixes #15206
Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.