From c7a23dfa0091b50e00657ac1c2d1bc54a23d9b4a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 9 Dec 2022 11:55:36 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/5400#issuecomment-1343797094 --- app/src/util/globalShortcut.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index 2f0f73b9a..a4e2b7255 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -396,6 +396,13 @@ export const globalShortcut = () => { const sideElement = currentLiElement.parentElement.previousElementSibling || currentLiElement.parentElement.nextElementSibling; (sideElement.querySelector(`[data-index="${currentLiElement.getAttribute("data-index")}"]`) || sideElement.lastElementChild).classList.add("b3-list-item--focus"); } + const currentRect = switchDialog.element.querySelector(".b3-list-item--focus").getBoundingClientRect(); + const currentParentRect = currentLiElement.parentElement.getBoundingClientRect(); + if (currentRect.top < currentParentRect.top) { + currentLiElement.scrollIntoView(true); + } else if (currentRect.bottom > currentParentRect.bottom) { + currentLiElement.scrollIntoView(false); + } } return; }