diff --git a/app/src/search/util.ts b/app/src/search/util.ts index 44993925d..0a74fb344 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -527,41 +527,49 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: () event.preventDefault(); break; } else if (target.id === "searchHistoryBtn") { - const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; - if (!list.keys || list.keys.length === 0) { - return; - } - let html = ""; - list.keys.forEach((s: string) => { - if (s !== searchInputElement.value) { - html += `
${escapeHtml(s)}
`; + if (historyElement.classList.contains("fn__none")) { + const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; + if (!list.keys || list.keys.length === 0) { + return; } - }); - if (html === "") { - return; + let html = ""; + list.keys.forEach((s: string) => { + if (s !== searchInputElement.value) { + html += `
${escapeHtml(s)}
`; + } + }); + if (html === "") { + return; + } + historyElement.classList.remove("fn__none"); + historyElement.innerHTML = html; + } else { + historyElement.classList.add("fn__none"); } - historyElement.classList.remove("fn__none"); - historyElement.innerHTML = html; replaceHistoryElement.classList.add("fn__none"); event.stopPropagation(); event.preventDefault(); return; } else if (target.id === "replaceHistoryBtn") { - const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; - if (!list.replaceKeys || list.replaceKeys.length === 0) { - return; - } - let html = ""; - list.replaceKeys.forEach((s: string) => { - if (s !== replaceInputElement.value) { - html += `
${escapeHtml(s)}
`; + if (replaceHistoryElement.classList.contains("fn__none")) { + const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; + if (!list.replaceKeys || list.replaceKeys.length === 0) { + return; } - }); - if (html === "") { - return; + let html = ""; + list.replaceKeys.forEach((s: string) => { + if (s !== replaceInputElement.value) { + html += `
${escapeHtml(s)}
`; + } + }); + if (html === "") { + return; + } + replaceHistoryElement.classList.remove("fn__none"); + replaceHistoryElement.innerHTML = html; + } else { + replaceHistoryElement.classList.add("fn__none"); } - replaceHistoryElement.classList.remove("fn__none"); - replaceHistoryElement.innerHTML = html; historyElement.classList.add("fn__none"); event.stopPropagation(); event.preventDefault();