Skip to content

Commit

Permalink
Update the CaretBrowsingMode toolbar-height if the toolbarDensity
Browse files Browse the repository at this point in the history
… preference changes (PR 18786 follow-up)

Otherwise the isVisible-calculations may not work correctly.
  • Loading branch information
Snuffleupagus committed Oct 1, 2024
1 parent f2a132f commit e9a77f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ const PDFViewerApplication = {

moveCaret(isUp, select) {
this._caretBrowsing ||= new CaretBrowsingMode(
this.eventBus,
this.appConfig.mainContainer,
this.appConfig.viewerContainer,
this.appConfig.toolbar?.container
Expand Down
14 changes: 12 additions & 2 deletions web/caret_browsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ class CaretBrowsingMode {

#viewerContainer;

constructor(mainContainer, viewerContainer, toolbarContainer) {
constructor(eventBus, mainContainer, viewerContainer, toolbarContainer) {
this.#mainContainer = mainContainer;
this.#viewerContainer = viewerContainer;
this.#toolBarHeight = toolbarContainer?.getBoundingClientRect().height ?? 0;

const computeToolBarHeight = () => {
this.#toolBarHeight =
toolbarContainer?.getBoundingClientRect().height ?? 0;
};
computeToolBarHeight();

eventBus._on("toolbardensity", async () => {
await Promise.resolve(); // Ensure that the UI has updated.
computeToolBarHeight();
});
}

/**
Expand Down

0 comments on commit e9a77f5

Please sign in to comment.