Skip to content

Commit

Permalink
fix: prevent the '/' being entered into the search input upon focus
Browse files Browse the repository at this point in the history
Signed-off-by: Venkata Sai <[email protected]>
  • Loading branch information
Venkata-Sai-Vishwanath-robo authored Jan 13, 2025
1 parent 747395c commit 135b57f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assets/js/offline-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@

//Bring focus to search bar
$(document).on('keydown', function (event) {
if (event.key === '/' ) {
if (event.key === '/' && !(document.activeElement instanceof HTMLInputElement)) {
event.preventDefault();
$searchInput.focus();
}
});
Expand All @@ -193,6 +194,10 @@
}
});

$searchInput.on('blur', function () {
$searchInput.val('');
$searchInput.trigger('change');
});

});
})(jQuery);

0 comments on commit 135b57f

Please sign in to comment.