From 1ecec0c6554ed7819dcced1784cd6a95b8c5c01f Mon Sep 17 00:00:00 2001 From: Gaurav Shandilya Date: Wed, 16 Oct 2024 13:10:13 +0530 Subject: [PATCH] fix: input focus on enter and popover instance --- assets/js/offline-search.js | 18 ++++-------------- layouts/partials/hotkey.html | 5 +++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/assets/js/offline-search.js b/assets/js/offline-search.js index 80db769a..3ff5df1f 100644 --- a/assets/js/offline-search.js +++ b/assets/js/offline-search.js @@ -14,7 +14,7 @@ render($(event.target)); // Hide keyboard on mobile browser - $searchInput.blur(); + // $searchInput.blur(); }); // Prevent reloading page by enter key on sidebar search. @@ -62,23 +62,13 @@ // Dispose existing popover // - { - let popover = bootstrap.Popover.getInstance($targetSearchInput[0]); - if (popover !== null) { - popover.dispose(); - } - } + bootstrap.Popover.getInstance($targetSearchInput[0])?.dispose(); // // Search // - - if (idx === null) { - return; - } - const searchQuery = $targetSearchInput.val(); - if (searchQuery === '') { + if (idx === null || searchQuery === "") { return; } @@ -182,7 +172,7 @@ //Bring focus to search bar $(document).on('keydown', function (event) { - if (event.key === '/') { + if (event.key === '/' ) { $searchInput.focus(); } }); diff --git a/layouts/partials/hotkey.html b/layouts/partials/hotkey.html index 6561782d..f3545af3 100644 --- a/layouts/partials/hotkey.html +++ b/layouts/partials/hotkey.html @@ -13,6 +13,11 @@ href="https://unpkg.com/keyboard-css@1.2.4/dist/css/main.min.css" />