diff --git a/views/browse_include.twig b/views/browse_include.twig index 666c7b9..3627a52 100644 --- a/views/browse_include.twig +++ b/views/browse_include.twig @@ -55,7 +55,7 @@ > Search 0 && $findBox.css("display") !== "none"; } @@ -119,7 +126,6 @@ class FindDialog { destroy() { document.removeEventListener("keydown", this._onKeydown); document.removeEventListener("keydown", this._onResize); - this._onKeydown = null; this._onResize = null; this._handler = null; FindDialog.instance = null; @@ -137,17 +143,7 @@ class FindDialog { * changed. */ #addListeners() { - if (!this._onKeydown) { - this._onKeydown = (event) => { - const { code, ctrlKey, metaKey } = event; - if ( - (code === "KeyF" && (ctrlKey || metaKey)) || - (code === "Escape" && this.isVisible) - ) { - this.toggle(); - } - }; - + if (!this._onResize) { this._onResize = () => { const navPanel = document.querySelector("#nav-panel"); @@ -174,7 +170,6 @@ class FindDialog { this.toggle(false); }; - document.addEventListener("keydown", this._onKeydown); window.addEventListener("resize", this._onResize); $(document).on("newTemplate", this._onNewTemplate); } @@ -273,7 +268,7 @@ class FindDialog { * The text is treated as a case-insensitive string, and the search is done * using the includes() method. */ -function openSearch() { +function toggleSearch() { if (FindDialog.exists) { FindDialog.instance.toggle(); } else { @@ -312,6 +307,27 @@ function openSearch() { } } +document.addEventListener("keydown", (event) => { + const { code, ctrlKey, metaKey } = event; + const platform = remote.getGlobal("platform"); + + // Ignore [Ctrl]+[f] on Mac + if (ctrlKey && platform === "mac") { + return; + } + + // Toggle the search dialog on: + // 1. [Meta]+[f] on a Mac + // 2. [Ctrl]+[f] on Windows + // 3. [Esc] on any platform if the search dialog is visible + if ( + ((ctrlKey || metaKey) && code === "KeyF") || + (code === "Escape" && FindDialog.isVisible) + ) { + toggleSearch(); + } +}); + /** * Sorts two elements by their data-key attribute in ascending or descending order * @param {String} key - the data-key attribute to sort by diff --git a/views/modals/installed.twig b/views/modals/installed.twig index 3867990..83e0385 100644 --- a/views/modals/installed.twig +++ b/views/modals/installed.twig @@ -11,7 +11,7 @@ Installed APP's
- + Search