| | |
| | | e.preventDefault() |
| | | // The results should already been focused, so we need to find the next one. |
| | | // The activeElement is the search bar, so we need to find the first result and focus it. |
| | | if (!results?.contains(document.activeElement)) { |
| | | if (document.activeElement === searchBar || currentHover !== null) { |
| | | const firstResult = currentHover |
| | | ? currentHover |
| | | : (document.getElementsByClassName("result-card")[0] as HTMLInputElement | null) |
| | |
| | | removeAllChildren(preview as HTMLElement) |
| | | } else { |
| | | firstChild.classList.add("focus") |
| | | currentHover = firstChild as HTMLInputElement |
| | | await displayPreview(firstChild) |
| | | } |
| | | } |
| | |
| | | searchLayout.style.opacity = "1" |
| | | } |
| | | |
| | | if (term === "" && searchLayout) { |
| | | searchLayout.style.opacity = "0" |
| | | } |
| | | |
| | | if (term.toLowerCase().startsWith("#")) { |
| | | searchType = "tags" |
| | | } else { |