From b8346b464920f9503946389d4e6b30e68e18e5e7 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 15 Jun 2024 10:53:06 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/11710 --- app/src/protyle/render/av/openMenuPanel.ts | 2 ++ app/src/protyle/render/av/select.ts | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index 96b360d85ef..b653e72f189 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -357,6 +357,7 @@ export const openMenuPanel = (options: { avID, data: oldData, }]); + const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; if (options.cellElements) { menuElement.innerHTML = getSelectHTML(data.view, options.cellElements); bindSelectEvent(options.protyle, data, menuElement, options.cellElements, options.blockElement); @@ -369,6 +370,7 @@ export const openMenuPanel = (options: { }); bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr, blockID}); } + menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll; return; } if (targetElement.getAttribute("data-type") === "setRelationCell") { diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts index d872e7c3338..858246e17d2 100644 --- a/app/src/protyle/render/av/select.ts +++ b/app/src/protyle/render/av/select.ts @@ -178,6 +178,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, return true; } }); + const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; if (!cellElements) { menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr}); bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID}); @@ -203,6 +204,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; }); if (menu.isOpen) { return; @@ -251,6 +253,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, return true; } }); + const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; if (!cellElements) { menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr}); bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID}); @@ -276,6 +279,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; }); } }); @@ -325,6 +329,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, return true; } }); + const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; if (!cellElements) { menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr}); bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID}); @@ -351,6 +356,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; name = inputElement.value; color = (index + 1).toString(); return true; @@ -528,9 +534,11 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H if (colData.type === "select") { menuElement.parentElement.remove(); } else { + const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; menuElement.innerHTML = getSelectHTML(data.view, cellElements); bindSelectEvent(protyle, data, menuElement, cellElements, blockElement); menuElement.querySelector("input").focus(); + menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll; } };