[Editor] Cleanup the pages not being fully rendered before switching to editing mode

In order to see the issue this patch is fixing:
 - open a pdf with some highlights and a comment on page 1, at page 7
 - open the comment sidebar
 - click on the comment on page 1

Opening at page 7 lets a not fully rendered page which means that when jumping to it
with the sidebar, we re-use what we've instead of redrawing it.
This commit is contained in:
Calixte Denizet 2025-09-10 10:23:20 +02:00
parent 5b7f9ca8b9
commit 0fc8986dc6
2 changed files with 6 additions and 0 deletions

View File

@ -1074,6 +1074,10 @@ class PDFPageView extends BasePDFPageView {
);
}
).then(async () => {
if (this.renderingState !== RenderingStates.FINISHED) {
// The rendering has been cancelled.
return;
}
this.structTreeLayer ||= new StructTreeLayerBuilder(
pdfPage,
viewport.rawDims

View File

@ -2502,6 +2502,8 @@ class PDFViewer {
if (!isEditing) {
this.pdfDocument.annotationStorage.resetModifiedIds();
}
// We need to cleanup whatever pages being rendered.
this.cleanup();
for (const pageView of this._pages) {
pageView.toggleEditingMode(isEditing);
}