From bfd877133b406eda3a46c2e5ac682262cca3e2c2 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Wed, 31 Jan 2024 20:09:04 +0000
Subject: [PATCH] fix: regression in formatted callout titles

---
 quartz/components/scripts/search.inline.ts |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts
index 0124e1f..170a8f0 100644
--- a/quartz/components/scripts/search.inline.ts
+++ b/quartz/components/scripts/search.inline.ts
@@ -20,8 +20,8 @@
 let searchType: SearchType = "basic"
 
 const contextWindowWords = 30
-const numSearchResults = 5
-const numTagResults = 3
+const numSearchResults = 8
+const numTagResults = 5
 function highlight(searchTerm: string, text: string, trim?: boolean) {
   // try to highlight longest tokens first
   const tokenizedTerms = searchTerm
@@ -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)
     }

--
Gitblit v1.10.0