fix(search): remove background with mouseEvent (#775)
* fix(search): remove background with mouseEvent make sure when mouseenter we remove all existing background Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> * chore: update logics from suggestions Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * revert: class is evicted * fix: address correct type Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> --------- Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com>
This commit is contained in:
parent
75d64eac91
commit
422986c98b
@ -281,12 +281,14 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function onMouseEnter(ev: MouseEvent) {
|
async function onMouseEnter(ev: MouseEvent) {
|
||||||
// When search is active, the first element is in focus, so we need to remove focus if given target is not the first element
|
// Actually when we hover, we need to clean all highlights within the result childs
|
||||||
const firstEl = document.getElementsByClassName("result-card")[0] as HTMLAnchorElement | null
|
for (const el of document.getElementsByClassName(
|
||||||
const target = ev.target as HTMLAnchorElement
|
"result-card",
|
||||||
if (firstEl !== target) {
|
) as HTMLCollectionOf<HTMLElement>) {
|
||||||
firstEl?.classList.remove("focus")
|
el.classList.remove("focus")
|
||||||
|
el.blur()
|
||||||
}
|
}
|
||||||
|
const target = ev.target as HTMLAnchorElement
|
||||||
target.classList.add("focus")
|
target.classList.add("focus")
|
||||||
await displayPreview(target)
|
await displayPreview(target)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user