Skip to content

Commit

Permalink
search: remove event loop when clearing results + pass thru which men…
Browse files Browse the repository at this point in the history
…u is open (#953)

* search: remove event loop when clearing results + pass thru which menu is open
* do not open search panel if closing results set and panel is closed already
  • Loading branch information
iisa authored Feb 16, 2022
1 parent 8ef6116 commit c76b617
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/BookNavigator/book-navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,19 @@ export class BookNavigator extends LitElement {
/* refresh br instance reference */
this.bookreader = brInstance;
}

this.updateMenuContents();

if (searchUpdates.openMenu === false) {
return;
}

if (this.isWideEnoughToOpenMenu && !searchUpdates?.searchCanceled) {
/* open side search menu */
setTimeout(() => {
this.updateSideMenu('search', 'open');
}, 0);
}
this.updateMenuContents();
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/BookNavigator/search/search-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export default class SearchProvider {
queryInProgress: false,
errorMessage: '',
};
this.updateMenu();
this.bookreader?.searchView?.clearSearchFieldAndResults();
this.updateMenu({ openMenu: false });
this.bookreader?.searchView?.clearSearchFieldAndResults(false);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/ia-bookreader/ia-bookreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class IaBookReader extends LitElement {
this.loaded = false;
this.menuShortcuts = [];
this.menuContents = [];
this.openMenuName = '';
}

updated() {
Expand Down Expand Up @@ -98,10 +99,11 @@ export class IaBookReader extends LitElement {
return;
}

this.openMenuName = menuId;

if (action === 'open') {
this.itemNav?.openShortcut(menuId);
} else if (action === 'toggle') {
this.itemNav?.openMenu(menuId);
this.itemNav?.toggleMenu();
}
}
Expand All @@ -119,6 +121,7 @@ export class IaBookReader extends LitElement {
?signedIn=${this.signedIn}
.menuShortcuts=${this.menuShortcuts}
.menuContents=${this.menuContents}
.openMenu=${this.openMenuName}
>
<div slot="header">
<slot name="header"></slot>
Expand Down

0 comments on commit c76b617

Please sign in to comment.