Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(searchbar): changed event listener to click #386

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the hotkey as well.

focusSearchBar();
});
Expand Down
Loading