aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--themes/simple/layouts/partials/search.html8
1 files changed, 6 insertions, 2 deletions
diff --git a/themes/simple/layouts/partials/search.html b/themes/simple/layouts/partials/search.html
index 7978000..adf2cfb 100644
--- a/themes/simple/layouts/partials/search.html
+++ b/themes/simple/layouts/partials/search.html
@@ -52,6 +52,7 @@
52 52
53 // On keyboard shortcut shows search modal. 53 // On keyboard shortcut shows search modal.
54 let currentSearchResultsSectionIndex = -1; 54 let currentSearchResultsSectionIndex = -1;
55 const itemHoverClass = 'bg-gray-100';
55 document.addEventListener('keydown', function(event) { 56 document.addEventListener('keydown', function(event) {
56 // Handles macOS CMD+k. 57 // Handles macOS CMD+k.
57 if ((event.ctrlKey || event.metaKey) && event.key === 'k') { 58 if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
@@ -65,6 +66,7 @@
65 showSearchModal(); 66 showSearchModal();
66 } 67 }
67 68
69
68 // If ESC is pressed when the input is empty close the search modal. 70 // If ESC is pressed when the input is empty close the search modal.
69 if (event.key === 'Escape' || event.key === 'Esc') { 71 if (event.key === 'Escape' || event.key === 'Esc') {
70 if (searchInput.value.length == 0) { 72 if (searchInput.value.length == 0) {
@@ -77,13 +79,15 @@
77 } 79 }
78 } 80 }
79 } else { 81 } else {
82 const listItems = searchResults.querySelectorAll('a');
83 listItems.forEach(el => el.classList.remove(itemHoverClass));
84 currentSearchResultsSectionIndex = -1;
80 searchInput.focus(); 85 searchInput.focus();
81 } 86 }
82 } 87 }
83 88
89
84 // Arrow UP/DOWN movement through search results. 90 // Arrow UP/DOWN movement through search results.
85 const list = document.querySelector('.ulist');
86 const itemHoverClass = 'bg-gray-100';
87 if (event.key === 'ArrowUp') { 91 if (event.key === 'ArrowUp') {
88 if (!searchResults.classList.contains('hidden')) { 92 if (!searchResults.classList.contains('hidden')) {
89 event.preventDefault(); 93 event.preventDefault();