From 3dcbaf4c378fbefd484d3beb7a0a405b2614c618 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 2 Dec 2023 21:02:06 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9794 --- app/src/boot/globalEvent/searchKeydown.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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);