Skip to content

Commit 0fc8986

Browse files
committed
[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.
1 parent 5b7f9ca commit 0fc8986

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

web/pdf_page_view.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,10 @@ class PDFPageView extends BasePDFPageView {
10741074
);
10751075
}
10761076
).then(async () => {
1077+
if (this.renderingState !== RenderingStates.FINISHED) {
1078+
// The rendering has been cancelled.
1079+
return;
1080+
}
10771081
this.structTreeLayer ||= new StructTreeLayerBuilder(
10781082
pdfPage,
10791083
viewport.rawDims

web/pdf_viewer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,8 @@ class PDFViewer {
25022502
if (!isEditing) {
25032503
this.pdfDocument.annotationStorage.resetModifiedIds();
25042504
}
2505+
// We need to cleanup whatever pages being rendered.
2506+
this.cleanup();
25052507
for (const pageView of this._pages) {
25062508
pageView.toggleEditingMode(isEditing);
25072509
}

0 commit comments

Comments
 (0)