Repository navigation
Fix listing pagination clicks updating the list twice - #15217
Merged
Merged
Conversation
Quarto's onclick on each page link set the page hash and also called showPage(). Returning false from an onclick property only cancels the link's default navigation; the click still bubbles to the listener that list.js's pagination plugin binds on the pagination list, which shows the same page again. Every click therefore ran list.update() and all "updated" handlers twice. show() is idempotent, so nothing visibly broke, but each handler did its work twice per click. list.js already shows the clicked page, so the onclick now only records the page hash. The new Playwright case counts update-handler runs for one pagination click (2 before, 1 after) in each browser.
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.
Clicking a page link in a website listing ran
list.update()twice, so everylist.on("updated")handler ran twice per click. Nothing changes on screen, as showing the same page twice gives the same result. Found while working on #15214.Root cause
Quarto sets an
onclickon each page link that writes the page into the URL hash and callsshowPage(). Returningfalseonly cancels the link navigation. The click still bubbles to the listener that the list.js pagination plugin binds on the pagination list, and that listener shows the same page again.This list.js listener was already in the vendored
list.min.jswhen theonclickwas added in e6111a3 to write the page into the URL. TheshowPage()call duplicated list.js from the start.Fix
The
onclicknow only records the page hash, and list.js shows the page.Tests
listing-update-handlers.spec.tsgets a case that clicks page 2 of each listing and counts handler runs: 2 before the fix, 1 after.listing-interactions.spec.tschecks the page hash and back navigation after a pagination click, and it passes unchanged.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.