Skip to content

Commit

Permalink
Merge pull request #386 from void-hr/fix/searchbar-click
Browse files Browse the repository at this point in the history
fix(searchbar): changed event listener to click
  • Loading branch information
vishalvivekm authored Oct 28, 2024
2 parents ca466d9 + ccea8fa commit 38cd2a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
18 changes: 4 additions & 14 deletions assets/js/offline-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -182,7 +172,7 @@

//Bring focus to search bar
$(document).on('keydown', function (event) {
if (event.key === '/') {
if (event.key === '/' ) {
$searchInput.focus();
}
});
Expand Down
7 changes: 6 additions & 1 deletion layouts/partials/hotkey.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
href="https://unpkg.com/[email protected]/dist/css/main.min.css"
/>
<script>
searchKey.addEventListener("mousedown", () => {
function focusSearchBar (){
var searchBar = document.querySelector(".td-search__input");
searchBar.focus();
}

searchKey.addEventListener("click", () => {
event.preventDefault();
focusSearchBar();
});
Expand Down

0 comments on commit 38cd2a3

Please sign in to comment.