From 1513b3d6ecf45c64f35bcef8600b6c5eb8056c23 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 21 Jun 2024 23:22:55 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/11710 --- app/src/protyle/render/av/select.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts index 83bdd3864..7ac6f725c 100644 --- a/app/src/protyle/render/av/select.ts +++ b/app/src/protyle/render/av/select.ts @@ -179,6 +179,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, } }); const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; + const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight; if (!cellElements) { menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr}); bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID}); @@ -204,7 +205,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, menuElement.innerHTML = getSelectHTML(data.view, cellElements); bindSelectEvent(protyle, data, menuElement, cellElements, blockElement); } - menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll; + menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight); }); if (menu.isOpen) { return; @@ -254,6 +255,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, } }); const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; + const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight; if (!cellElements) { menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr}); bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID}); @@ -279,7 +281,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, menuElement.innerHTML = getSelectHTML(data.view, cellElements); bindSelectEvent(protyle, data, menuElement, cellElements, blockElement); } - menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll; + menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight); }); } }); @@ -535,10 +537,11 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H menuElement.parentElement.remove(); } else { const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; + const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight; menuElement.innerHTML = getSelectHTML(data.view, cellElements); bindSelectEvent(protyle, data, menuElement, cellElements, blockElement); menuElement.querySelector("input").focus(); - menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll; + menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight); } };