Skip to content

Commit 6f0d8d5

Browse files
Merge pull request #20695 from calixteman/bug2018125
Update the page count in the UI when some changes are done (bug 2018125)
2 parents 82de224 + bd3f14f commit 6f0d8d5

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

test/integration/reorganize_pages_spec.mjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,40 @@ describe("Reorganize Pages View", () => {
686686
})
687687
);
688688
});
689+
690+
it("should update the page count in the toolbar after deletion (bug 2018125)", async () => {
691+
await Promise.all(
692+
pages.map(async ([browserName, page]) => {
693+
await waitForThumbnailVisible(page, 1);
694+
await page.waitForSelector("#viewsManagerStatusActionButton", {
695+
visible: true,
696+
});
697+
698+
const initialCount = await page.$eval("#pageNumber", el => el.max);
699+
expect(parseInt(initialCount, 10))
700+
.withContext(`In ${browserName}`)
701+
.toBe(17);
702+
703+
await waitAndClick(
704+
page,
705+
`.thumbnail:has(${getThumbnailSelector(1)}) input`
706+
);
707+
await waitAndClick(
708+
page,
709+
`.thumbnail:has(${getThumbnailSelector(3)}) input`
710+
);
711+
712+
const handlePagesEdited = await waitForPagesEdited(page);
713+
await waitAndClick(page, "#viewsManagerStatusActionButton");
714+
await waitAndClick(page, "#viewsManagerStatusActionDelete");
715+
await awaitPromise(handlePagesEdited);
716+
717+
await page.waitForFunction(
718+
() => document.querySelector("#pageNumber").max === "15"
719+
);
720+
})
721+
);
722+
});
689723
});
690724

691725
describe("Cut and paste some pages", () => {

web/toolbar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ class Toolbar {
237237
value: this.value,
238238
});
239239
});
240+
eventBus._on("pagesedited", ({ pagesMapper }) => {
241+
const pagesCount = pagesMapper.pagesNumber;
242+
if (pagesCount !== this.pagesCount) {
243+
this.setPagesCount(pagesCount, this.hasPageLabels);
244+
}
245+
});
240246

241247
scaleSelect.addEventListener("change", function () {
242248
if (this.value === "custom") {

0 commit comments

Comments
 (0)