Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/12006

Vanessa9d4eef08e94a
diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts
index 7ac6f725ca..42e40f2aac 100644
--- a/app/src/protyle/render/av/select.ts
+++ b/app/src/protyle/render/av/select.ts
@@ -179,7 +179,8 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
}
});
const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop;
- const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight;
+ const selectedElement = menuElement.querySelector(".b3-chips")
+ const oldChipsHeight = selectedElement ? selectedElement.clientHeight : 0;
if (!cellElements) {
menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr});
bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID});
@@ -205,13 +206,16 @@ 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-chips").clientHeight - oldChipsHeight);
+ if (selectedElement) {
+ menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);
+ }
});
if (menu.isOpen) {
return;
}
menu.addItem({
iconHTML: "",
+ type: "readonly",
label: `<input class="b3-text-field" style="margin: 4px 0" value="${name}">`,
bind(element) {
element.querySelector("input").addEventListener("keydown", (event: KeyboardEvent) => {
@@ -255,7 +259,8 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
}
});
const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop;
- const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight;
+ const selectedElement = menuElement.querySelector(".b3-chips")
+ const oldChipsHeight = selectedElement?selectedElement.clientHeight:0;
if (!cellElements) {
menuElement.innerHTML = getEditHTML({protyle, data, colId, isCustomAttr});
bindEditEvent({protyle, data, menuElement, isCustomAttr, blockID});
@@ -281,7 +286,9 @@ 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-chips").clientHeight - oldChipsHeight);
+ if (selectedElement) {
+ menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);
+ }
});
}
});
@@ -541,7 +548,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
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-chips").clientHeight - oldChipsHeight);
+ menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);
}
};