From 03174662a2b80b9faecbdcde61a77883a51591cc Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 28 Oct 2026 12:16:33 +0100 Subject: [PATCH 1/2] Stop listing pagination clicks from updating the list twice 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. --- .../projects/website/listing/quarto-listing.js | 3 ++- .../tests/listing-update-handlers.spec.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/resources/projects/website/listing/quarto-listing.js b/src/resources/projects/website/listing/quarto-listing.js index 7e2a9f4285..6006b2c2a7 100644 --- a/src/resources/projects/website/listing/quarto-listing.js +++ b/src/resources/projects/website/listing/quarto-listing.js @@ -136,9 +136,10 @@ function refreshPaginationHandlers(listingId) { ".pagination li.page-item:not(.disabled) .page.page-link" ); for (const paginationEl of paginationEls) { + // list.js's pagination plugin shows the page from its own click + // listener on the pagination list; this handler only records the hash. paginationEl.onclick = (sender) => { setPageHash(listingId, sender.target.getAttribute("data-i")); - showPage(listingId, sender.target.getAttribute("data-i")); return false; }; } diff --git a/tests/integration/playwright/tests/listing-update-handlers.spec.ts b/tests/integration/playwright/tests/listing-update-handlers.spec.ts index ff610626a5..e269a233e4 100644 --- a/tests/integration/playwright/tests/listing-update-handlers.spec.ts +++ b/tests/integration/playwright/tests/listing-update-handlers.spec.ts @@ -26,8 +26,7 @@ async function countUpdateHandlerRuns(page: Page) { }); } -// A pagination click updates the list twice (list.js and Quarto both handle -// it), so trigger exactly one update through the List.js API instead. +// Trigger exactly one update through the List.js API. async function updateRunsForOneUpdate(page: Page, listingId: string) { return page.evaluate((id) => { const w = window as any; @@ -56,5 +55,17 @@ test.describe("Listing update handlers", () => { expect(await updateRunsForOneUpdate(page, listingId)).toBe(1); }); + + test(`${listingId} updates once per pagination click`, async ({ page }) => { + await page.goto(fixture); + await countUpdateHandlerRuns(page); + + const id = `listing-${listingId}`; + await page.locator(`#${id} .pagination .page-link[data-i="2"]`).click(); + + await expect(page).toHaveURL(new RegExp(`${id}-page=2`)); + expect(await page.evaluate((id) => (window as any).updateRuns[id], id)) + .toBe(1); + }); } }); From bdf1fc72e1df4f9435384c5ce0da0c68313c817c Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 28 Oct 2026 12:36:53 +0100 Subject: [PATCH 2/2] Add changelog entry for listing pagination double update --- news/changelog-1.11.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.11.md b/news/changelog-1.11.md index 441176619a..af57b8f2da 100644 --- a/news/changelog-1.11.md +++ b/news/changelog-1.11.md @@ -144,6 +144,7 @@ All changes included in 1.11: - ([#15091](https://github.com/quarto-dev/quarto-cli/pull/15091)): Fix `open-graph: false` or `twitter-card: false` in page front matter or `_metadata.yml` not disabling Open Graph or Twitter Card metadata for that page when the website enables it. - ([#15114](https://github.com/quarto-dev/quarto-cli/pull/15114)): Fix a website category containing backticks showing broken text in the page title block, and a category containing a backslash, such as a Windows path, failing the render or losing its backslashes. - ([#15206](https://github.com/quarto-dev/quarto-cli/issues/15206)): Fix website listings attaching another update handler on every URL hash change, and an extra one per additional listing on the same page. +- ([#15217](https://github.com/quarto-dev/quarto-cli/pull/15217)): Fix website listings updating twice for each click on a pagination link. ## Lua API