Make sure the focus moves on the first page of the added pdf after a merge (bug 2034827)

This commit is contained in:
Calixte Denizet 2026-05-05 16:17:02 +02:00
parent cd1b5f57c7
commit a6cb30a9e5
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
3 changed files with 14 additions and 3 deletions

View File

@ -3084,6 +3084,12 @@ describe("Reorganize Pages View", () => {
() => parseInt(document.getElementById("pageNumber").max, 10) === 6
);
// Focus must move to the first newly inserted page (page 3, since
// we merged after page 2).
await page.waitForFunction(
() => window.PDFViewerApplication.page === 3
);
// Pages 12 come from the original document, then all 3 pages of
// the merged PDF, then pages 46 of the original shifted to the end.
await waitForHavingContents(page, [1, 2, 1, 2, 3, 3]);

View File

@ -1874,7 +1874,8 @@ const PDFViewerApplication = {
}
this.pdfHistory.initialize({
fingerprint,
resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
resetHistory:
viewOnLoad === ViewOnLoad.INITIAL || !!this._mergedDocumentNeedsSaving,
updateUrl: AppOptions.get("historyUpdateUrl"),
});
@ -2440,6 +2441,7 @@ const PDFViewerApplication = {
return;
}
this._mergedDocumentNeedsSaving = true;
this.open({
data: modifiedPdfBytes,
filename: this._docFilename,

View File

@ -338,7 +338,7 @@ class PDFThumbnailViewer {
insertAfter: currentPageIndex ?? -1,
});
this.eventBus._on(
"thumbnailsloaded",
"pagesloaded",
() => {
// Clear any pre-merge selection: thumbnails are rebuilt fresh
// (all unchecked), so the old set would cause a label/visual
@ -358,7 +358,10 @@ class PDFThumbnailViewer {
this.#selectPage(i + 1, true);
}
if (insertedPagesCount) {
this.#updateCurrentPage(currentPageIndex + 2);
this.#updateCurrentPage(
currentPageIndex + 2,
/* force = */ true
);
}
},
{ once: true }