From 5a22155e9f03f14f29efbdd64d34480578b9c07c Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 27 Nov 2022 17:58:55 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20https://github.com/siyuan-note/siy?= =?UTF-8?q?uan/issues/4772=20=E4=B8=8A=E4=B8=8B=E9=94=AE=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/search/util.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/search/util.ts b/app/src/search/util.ts index 1f9ddb34f..2947fd006 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -383,7 +383,15 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: () if (event.key === "ArrowDown") { currentList.classList.remove("b3-list-item--focus"); if (!currentList.nextElementSibling) { - searchPanelElement.children[0].classList.add("b3-list-item--focus"); + if (config.group === 1) { + if (currentList.parentElement.nextElementSibling) { + currentList.parentElement.nextElementSibling.nextElementSibling.firstElementChild.classList.add("b3-list-item--focus"); + } else { + searchPanelElement.children[1].firstElementChild.classList.add("b3-list-item--focus"); + } + } else { + searchPanelElement.firstElementChild.classList.add("b3-list-item--focus"); + } } else { currentList.nextElementSibling.classList.add("b3-list-item--focus"); } @@ -401,8 +409,15 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: () } else if (event.key === "ArrowUp") { currentList.classList.remove("b3-list-item--focus"); if (!currentList.previousElementSibling) { - const length = searchPanelElement.children.length; - searchPanelElement.children[length - 1].classList.add("b3-list-item--focus"); + if (config.group === 1) { + if (currentList.parentElement.previousElementSibling.previousElementSibling) { + currentList.parentElement.previousElementSibling.previousElementSibling.lastElementChild.classList.add("b3-list-item--focus"); + } else { + searchPanelElement.lastElementChild.lastElementChild.classList.add("b3-list-item--focus"); + } + } else { + searchPanelElement.lastElementChild.classList.add("b3-list-item--focus"); + } } else { currentList.previousElementSibling.classList.add("b3-list-item--focus"); } @@ -589,6 +604,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbe inputTimeout = window.setTimeout(() => { loadingElement.classList.remove("fn__none"); const inputValue = searchInputElement.value; + element.querySelector("#searchList").scrollTo(0, 0); if (inputValue === "") { fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { onSearch(response.data, edit, element);