mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
chore(search): check for input type and assignment of focus (#785)
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
parent
295b8fc914
commit
f78b512436
1 changed files with 2 additions and 1 deletions
|
@ -238,7 +238,7 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||
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)
|
||||
|
@ -398,6 +398,7 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||
removeAllChildren(preview as HTMLElement)
|
||||
} else {
|
||||
firstChild.classList.add("focus")
|
||||
currentHover = firstChild as HTMLInputElement
|
||||
await displayPreview(firstChild)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue