Repository navigation
Fix listing page hash lost on a click right after a page change - #15233
Merged
Merged
Conversation
list.js rebuilds the pagination links on every update, and the handler that writes the page hash (and blocks the links' href="#") was only re-attached in a setTimeout after each update. A click on a rebuilt link before that timer fired changed the page through list.js but followed href="#", leaving the URL at index.html# with no page hash. This showed up as an intermittent firefox failure of the page hash Playwright test on the macOS nightly run. The deferral could not simply be dropped: list.js dispatches "updated" handlers in reverse registration order, so our handler runs before the pagination plugin rebuilds the links. Instead, attach one click listener per listing on its ul.pagination, which list.js keeps across updates, so there is no window without a handler. The new test clicks page 2 then page 3 in a single task, so no timer can run between the update and the second click; it failed in chromium, firefox and webkit before this change.
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. |
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.
When a listing page link is clicked right after the previous page change, the listing shows the new page but the page hash is not written: the URL ends at
index.html#. This made the page hash test added in #15214 fail intermittently in firefox on the nightly macOS run.Root cause
list.js rebuilds the pagination links on every list update. The click handler that writes the page hash, and blocks the links'
href="#", was put back on the new links in asetTimeoutafter each update (src/resources/projects/website/listing/quarto-listing.js:63). A click landing before that timer fires still changes the page through list.js's own listener, but followshref="#".The timer can't just be dropped: list.js runs
updatedhandlers in reverse registration order, so our handler runs before the links are rebuilt.Fix
One click listener per listing on its
ul.pagination, which list.js keeps across updates, so rebuilt links are covered from the start.The new test clicks page 2 then page 3 in the same task, so no timer can run in between. It failed in chromium, firefox and webkit before the fix.
No changelog entry, as a user would hardly click fast enough to hit this.
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.