From 135b57f5ac05e7efeea2936699cae3f79c61a51d Mon Sep 17 00:00:00 2001 From: Venkata Sai <116882464+Venkata-Sai-Vishwanath-robo@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:47:41 +0530 Subject: [PATCH] fix: prevent the '/' being entered into the search input upon focus Signed-off-by: Venkata Sai <116882464+Venkata-Sai-Vishwanath-robo@users.noreply.github.com> --- assets/js/offline-search.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/js/offline-search.js b/assets/js/offline-search.js index 3ff5df1f..9d775015 100644 --- a/assets/js/offline-search.js +++ b/assets/js/offline-search.js @@ -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(); } }); @@ -193,6 +194,10 @@ } }); + $searchInput.on('blur', function () { + $searchInput.val(''); + $searchInput.trigger('change'); + }); + }); })(jQuery); - \ No newline at end of file