瀏覽代碼

:art: fix https://github.com/siyuan-note/siyuan/issues/11710

Vanessa 1 年之前
父節點
當前提交
b8346b4649
共有 2 個文件被更改,包括 10 次插入0 次删除
  1. 2 0
      app/src/protyle/render/av/openMenuPanel.ts
  2. 8 0
      app/src/protyle/render/av/select.ts

+ 2 - 0
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") {

+ 8 - 0
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;
     }
 };