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); } };