Merge pull request #21145 from calixteman/bug2034461

Prompt the user for saving a merged pdf (bug 2034461)
This commit is contained in:
calixteman 2026-04-24 14:11:36 +02:00 committed by GitHub
commit a6382ac97d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 1 deletions

View File

@ -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();
})
);
});
}); });
}); });

View File

@ -1352,6 +1352,8 @@ const PDFViewerApplication = {
? this.save() ? this.save()
: this.download()); : this.download());
} }
delete this._mergedDocumentNeedsSaving;
this.setTitle();
classList.remove("wait"); classList.remove("wait");
}, },
@ -1898,7 +1900,8 @@ const PDFViewerApplication = {
_hasChanges() { _hasChanges() {
return ( return (
this.pdfDocument?.annotationStorage.size > 0 || this.pdfDocument?.annotationStorage.size > 0 ||
this.pdfThumbnailViewer?.hasStructuralChanges() this.pdfThumbnailViewer?.hasStructuralChanges() ||
this._mergedDocumentNeedsSaving === true
); );
}, },
@ -2436,6 +2439,7 @@ const PDFViewerApplication = {
); );
return; return;
} }
this._mergedDocumentNeedsSaving = true;
this.open({ this.open({
data: modifiedPdfBytes, data: modifiedPdfBytes,
filename: this._docFilename, filename: this._docFilename,