mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Close docs search box when an entry is selected
This comes up when clicking a link that changes the fragment only, meaning the page doesn't transition and the box doesn't get closed that way.
This commit is contained in:
parent
ec2b8f9676
commit
c5d07c07ec
1 changed files with 9 additions and 2 deletions
|
@ -34,9 +34,10 @@ const setupSearch = () => {
|
|||
let searchForm = document.getElementById("module-search-form");
|
||||
let topSearchResultListItem = undefined;
|
||||
|
||||
// Hide the results whenever anyone clicks outside the search results.
|
||||
// Hide the results whenever anyone clicks outside the search results,
|
||||
// or on a specific search result.
|
||||
window.addEventListener("click", function (event) {
|
||||
if (!searchForm?.contains(event.target)) {
|
||||
if (!searchForm?.contains(event.target) || event.target.closest("#search-type-ahead a")) {
|
||||
searchTypeAhead.classList.add("hidden");
|
||||
}
|
||||
});
|
||||
|
@ -101,6 +102,12 @@ const setupSearch = () => {
|
|||
|
||||
break;
|
||||
}
|
||||
case "Enter": {
|
||||
// In case this is just an anchor link (which will move the scroll bar but not
|
||||
// reload the page), hide the search bar.
|
||||
searchTypeAhead.classList.add("hidden");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue