Skip to content

Commit daf4cd0

Browse files
Merge pull request #13220 from Snuffleupagus/currentOutlineItemPromise-isPagesLoaded
Ensure that `currentOutlineButton` enabling/disabling won't depend on the exact timing of the "pagesloaded" event (PR 13212 follow-up)
2 parents 4ac1082 + f285e41 commit daf4cd0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

web/pdf_outline_viewer.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ class PDFOutlineViewer extends BaseTreeViewer {
5454
this.eventBus._on("pagesloaded", evt => {
5555
this._isPagesLoaded = !!evt.pagesCount;
5656

57-
// If the capability is still pending, note the `_dispatchEvent`-method,
58-
// we know that the `currentOutlineItem`-button should be enabled here.
57+
// If the capability is still pending, see the `_dispatchEvent`-method,
58+
// we know that the `currentOutlineItem`-button can be enabled here.
5959
if (
6060
this._currentOutlineItemCapability &&
6161
!this._currentOutlineItemCapability.settled
6262
) {
63-
this._currentOutlineItemCapability.resolve(/* enabled = */ true);
63+
this._currentOutlineItemCapability.resolve(
64+
/* enabled = */ this._isPagesLoaded
65+
);
6466
}
6567
});
6668
this.eventBus._on("sidebarviewchanged", evt => {
@@ -95,6 +97,8 @@ class PDFOutlineViewer extends BaseTreeViewer {
9597
this._pdfDocument?.loadingParams.disableAutoFetch
9698
) {
9799
this._currentOutlineItemCapability.resolve(/* enabled = */ false);
100+
} else if (this._isPagesLoaded) {
101+
this._currentOutlineItemCapability.resolve(/* enabled = */ true);
98102
}
99103

100104
this.eventBus.dispatch("outlineloaded", {

0 commit comments

Comments
 (0)