Skip to content

Commit 823a0b2

Browse files
committed
Hide desktop search dropdown when clicking outside
1 parent 85ac545 commit 823a0b2

File tree

1 file changed

+14
-0
lines changed
  • lib/rdoc/generator/template/aliki/js

1 file changed

+14
-0
lines changed

lib/rdoc/generator/template/aliki/js/aliki.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ function hookSearch() {
9797
const search = createSearchInstance(input, result);
9898
if (!search) return;
9999

100+
// Hide search results when clicking outside the search area
101+
document.addEventListener('click', (e) => {
102+
if (!e.target.closest('.navbar-search-desktop')) {
103+
result.setAttribute('aria-expanded', 'false');
104+
}
105+
});
106+
107+
// Show search results when focusing on input (if there's a query)
108+
input.addEventListener('focus', () => {
109+
if (input.value.trim()) {
110+
result.setAttribute('aria-expanded', 'true');
111+
}
112+
});
113+
100114
// Check for ?q= URL parameter and trigger search automatically
101115
if (typeof URLSearchParams !== 'undefined') {
102116
const urlParams = new URLSearchParams(window.location.search);

0 commit comments

Comments
 (0)