From 91059843ae9122bd547ddfdfa5a30edd99a42ff7 Mon Sep 17 00:00:00 2001
From: reagenzn <aiooksa929@gmail.com>
Date: Fri, 01 Aug 2025 15:57:32 +0000
Subject: [PATCH] fix(search): prevent Enter key handling during IME composition (#2070)
---
quartz/components/scripts/search.inline.ts | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts
index 1f4c009..28d47e9 100644
--- a/quartz/components/scripts/search.inline.ts
+++ b/quartz/components/scripts/search.inline.ts
@@ -147,8 +147,7 @@
const container = searchElement.querySelector(".search-container") as HTMLElement
if (!container) return
- const sidebar = container.closest(".sidebar") as HTMLElement
- if (!sidebar) return
+ const sidebar = container.closest(".sidebar") as HTMLElement | null
const searchButton = searchElement.querySelector(".search-button") as HTMLButtonElement
if (!searchButton) return
@@ -180,7 +179,7 @@
function hideSearch() {
container.classList.remove("active")
searchBar.value = "" // clear the input when we dismiss the search
- sidebar.style.zIndex = ""
+ if (sidebar) sidebar.style.zIndex = ""
removeAllChildren(results)
if (preview) {
removeAllChildren(preview)
@@ -192,7 +191,7 @@
function showSearch(searchTypeNew: SearchType) {
searchType = searchTypeNew
- sidebar.style.zIndex = "1"
+ if (sidebar) sidebar.style.zIndex = "1"
container.classList.add("active")
searchBar.focus()
}
@@ -221,7 +220,7 @@
// If search is active, then we will render the first result and display accordingly
if (!container.classList.contains("active")) return
- if (e.key === "Enter") {
+ if (e.key === "Enter" && !e.isComposing) {
// If result has focus, navigate to that one, otherwise pick first result
if (results.contains(document.activeElement)) {
const active = document.activeElement as HTMLInputElement
@@ -301,9 +300,11 @@
itemTile.classList.add("result-card")
itemTile.id = slug
itemTile.href = resolveUrl(slug).toString()
- itemTile.innerHTML = `<h3>${title}</h3>${htmlTags}${
- enablePreview && window.innerWidth > 600 ? "" : `<p>${content}</p>`
- }`
+ itemTile.innerHTML = `
+ <h3 class="card-title">${title}</h3>
+ ${htmlTags}
+ <p class="card-description">${content}</p>
+ `
itemTile.addEventListener("click", (event) => {
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
hideSearch()
--
Gitblit v1.10.0