Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/resources/projects/website/listing/quarto-listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
Expand Down
15 changes: 13 additions & 2 deletions tests/integration/playwright/tests/listing-update-handlers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
}
});
Loading