Przeglądaj źródła

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

Vanessa 1 rok temu
rodzic
commit
1513b3d6ec
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6 3
      app/src/protyle/render/av/select.ts

+ 6 - 3
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);
     }
 };