From 302bc5f4d97a5217a604e48ed62281d785a77e23 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 23 Apr 2026 18:37:56 +0200 Subject: [PATCH] Prompt the user for saving a merged pdf (bug 2034461) --- test/integration/reorganize_pages_spec.mjs | 27 ++++++++++++++++++++++ web/app.js | 6 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/integration/reorganize_pages_spec.mjs b/test/integration/reorganize_pages_spec.mjs index 0310cc3dd..43d0f7de1 100644 --- a/test/integration/reorganize_pages_spec.mjs +++ b/test/integration/reorganize_pages_spec.mjs @@ -3096,5 +3096,32 @@ describe("Reorganize Pages View", () => { }) ); }); + + it("must mark document as needing save after merge (bug 2034461)", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + await waitForThumbnailVisible(page, 1); + + const handleMerged = await createPromise(page, resolve => { + window.PDFViewerApplication.eventBus._on( + "thumbnailsloaded", + resolve, + { once: true } + ); + }); + + const picker = await page.$("#viewsManagerAddFilePicker"); + await picker.uploadFile( + path.join(__dirname, "../pdfs/three_pages_with_number.pdf") + ); + await awaitPromise(handleMerged); + + const hasChanges = await page.evaluate(() => + window.PDFViewerApplication._hasChanges() + ); + expect(hasChanges).withContext(`In ${browserName}`).toBeTrue(); + }) + ); + }); }); }); diff --git a/web/app.js b/web/app.js index 859e22da1..4589b5f37 100644 --- a/web/app.js +++ b/web/app.js @@ -1352,6 +1352,8 @@ const PDFViewerApplication = { ? this.save() : this.download()); } + delete this._mergedDocumentNeedsSaving; + this.setTitle(); classList.remove("wait"); }, @@ -1898,7 +1900,8 @@ const PDFViewerApplication = { _hasChanges() { return ( this.pdfDocument?.annotationStorage.size > 0 || - this.pdfThumbnailViewer?.hasStructuralChanges() + this.pdfThumbnailViewer?.hasStructuralChanges() || + this._mergedDocumentNeedsSaving === true ); }, @@ -2436,6 +2439,7 @@ const PDFViewerApplication = { ); return; } + this._mergedDocumentNeedsSaving = true; this.open({ data: modifiedPdfBytes, filename: this._docFilename,