Update the page count in the UI when some changes are done (bug 2018125)

This commit is contained in:
Calixte Denizet 2026-02-20 18:06:48 +01:00
parent 34ba2064e6
commit bd3f14f62d
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
2 changed files with 40 additions and 0 deletions

View File

@ -686,6 +686,40 @@ describe("Reorganize Pages View", () => {
})
);
});
it("should update the page count in the toolbar after deletion (bug 2018125)", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await waitForThumbnailVisible(page, 1);
await page.waitForSelector("#viewsManagerStatusActionButton", {
visible: true,
});
const initialCount = await page.$eval("#pageNumber", el => el.max);
expect(parseInt(initialCount, 10))
.withContext(`In ${browserName}`)
.toBe(17);
await waitAndClick(
page,
`.thumbnail:has(${getThumbnailSelector(1)}) input`
);
await waitAndClick(
page,
`.thumbnail:has(${getThumbnailSelector(3)}) input`
);
const handlePagesEdited = await waitForPagesEdited(page);
await waitAndClick(page, "#viewsManagerStatusActionButton");
await waitAndClick(page, "#viewsManagerStatusActionDelete");
await awaitPromise(handlePagesEdited);
await page.waitForFunction(
() => document.querySelector("#pageNumber").max === "15"
);
})
);
});
});
describe("Cut and paste some pages", () => {

View File

@ -237,6 +237,12 @@ class Toolbar {
value: this.value,
});
});
eventBus._on("pagesedited", ({ pagesMapper }) => {
const pagesCount = pagesMapper.pagesNumber;
if (pagesCount !== this.pagesCount) {
this.setPagesCount(pagesCount, this.hasPageLabels);
}
});
scaleSelect.addEventListener("change", function () {
if (this.value === "custom") {