Aaron Pham
2024-01-31 422986c98babf19f00fc65078e3167eba5aaf7f7
quartz/components/scripts/search.inline.ts
@@ -281,12 +281,14 @@
    })
    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
      const firstEl = document.getElementsByClassName("result-card")[0] as HTMLAnchorElement | null
      const target = ev.target as HTMLAnchorElement
      if (firstEl !== target) {
        firstEl?.classList.remove("focus")
      // Actually when we hover, we need to clean all highlights within the result childs
      for (const el of document.getElementsByClassName(
        "result-card",
      ) as HTMLCollectionOf<HTMLElement>) {
        el.classList.remove("focus")
        el.blur()
      }
      const target = ev.target as HTMLAnchorElement
      target.classList.add("focus")
      await displayPreview(target)
    }