diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.ts index c8bb6ed2b..3995433b6 100644 --- a/app/src/boot/globalEvent/searchKeydown.ts +++ b/app/src/boot/globalEvent/searchKeydown.ts @@ -53,10 +53,6 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => { const assetsElement = element.querySelector("#searchAssets"); const isAsset = !assetsElement.classList.contains("fn__none"); const listElement = isAsset ? assetsElement.querySelector("#searchAssetList") : element.querySelector("#searchList"); - let currentList: HTMLElement = listElement.querySelector(".b3-list-item--focus"); - if (!currentList) { - return false; - } const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement; if (!isAsset && matchHotKey(window.siyuan.config.keymap.general.newFile.custom, event)) { newFileByName(app, searchInputElement.value); @@ -80,6 +76,10 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => { // 不能返回 true,否则历史菜单无法使用快捷键 return false; } + let currentList: HTMLElement = listElement.querySelector(".b3-list-item--focus"); + if (!currentList) { + return false; + } if (currentList.getAttribute("data-type") === "search-new") { if (event.key === "Enter") { newFileByName(app, searchInputElement.value);