From a0b927da4aa9bb540b50c875e77f97bd4a7c279a Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Fri, 02 Feb 2024 09:24:40 +0000
Subject: [PATCH] fix: use display instead of visibility for click handling pasthrough
---
quartz/components/scripts/search.inline.ts | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts
index 2924f39..abdef06 100644
--- a/quartz/components/scripts/search.inline.ts
+++ b/quartz/components/scripts/search.inline.ts
@@ -188,7 +188,7 @@
removeAllChildren(preview)
}
if (searchLayout) {
- searchLayout.style.visibility = "hidden"
+ searchLayout.classList.remove("display-results")
}
searchType = "basic" // reset search type after closing
@@ -424,7 +424,7 @@
async function onType(e: HTMLElementEventMap["input"]) {
if (!searchLayout || !index) return
currentSearchTerm = (e.target as HTMLInputElement).value
- searchLayout.style.visibility = currentSearchTerm === "" ? "hidden" : "visible"
+ searchLayout.classList.toggle("display-results", currentSearchTerm !== "")
searchType = currentSearchTerm.startsWith("#") ? "tags" : "basic"
let searchResults: FlexSearch.SimpleDocumentSearchResultSetUnit[]
@@ -464,8 +464,8 @@
searchBar?.addEventListener("input", onType)
window.addCleanup(() => searchBar?.removeEventListener("input", onType))
- await fillDocument(data)
registerEscapeHandler(container, hideSearch)
+ await fillDocument(data)
})
/**
@@ -475,13 +475,18 @@
*/
async function fillDocument(data: { [key: FullSlug]: ContentDetails }) {
let id = 0
+ const promises: Array<Promise<unknown>> = []
for (const [slug, fileData] of Object.entries<ContentDetails>(data)) {
- await index.addAsync(id++, {
- id,
- slug: slug as FullSlug,
- title: fileData.title,
- content: fileData.content,
- tags: fileData.tags,
- })
+ promises.push(
+ index.addAsync(id++, {
+ id,
+ slug: slug as FullSlug,
+ title: fileData.title,
+ content: fileData.content,
+ tags: fileData.tags,
+ }),
+ )
}
+
+ return await Promise.all(promises)
}
--
Gitblit v1.10.0