An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Stabilize database relation popup sizing and positioning https://github.com/siyuan-note/siyuan/issues/14028
Daniel76989c1ab459
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.tsindex 5531ce2ee8..a6899ea441 100644--- a/app/src/protyle/render/av/relation.ts+++ b/app/src/protyle/render/av/relation.ts@@ -369,6 +369,43 @@ export const bindRelationEvent = (options: {controller: undefined as AbortController | undefined,};let searchTimer: number;+ let listNaturalMaxHeight = 0;+ let positionInitialized = false;++ const resetPosition = () => {+ options.menuElement.removeAttribute("data-position-top");+ options.menuElement.removeAttribute("data-position-bottom");+ options.menuElement.removeAttribute("data-position-x");+ };+ const updateListMaxHeight = () => {+ if (listNaturalMaxHeight < 1) {+ return false;+ }+ const menuStyle = getComputedStyle(options.menuElement);+ const maxMenuHeight = parseFloat(menuStyle.maxHeight) || window.innerHeight - 32;+ const headerHeight = listElement.previousElementSibling?.getBoundingClientRect().height || 0;+ const chromeHeight = headerHeight + parseFloat(menuStyle.paddingTop) + parseFloat(menuStyle.paddingBottom) ++ parseFloat(menuStyle.borderTopWidth) + parseFloat(menuStyle.borderBottomWidth);+ const maxHeight = Math.max(30, Math.min(listNaturalMaxHeight, maxMenuHeight - chromeHeight));+ const maxHeightValue = maxHeight + "px";+ if (listElement.style.maxHeight === maxHeightValue) {+ return false;+ }+ listElement.style.maxHeight = maxHeightValue;+ return true;+ };+ const positionMenu = (reset = false) => {+ if (reset) {+ resetPosition();+ }+ const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();+ setPosition(options.menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);+ positionInitialized = true;+ };+ const resize = () => {+ updateListMaxHeight();+ positionMenu(true);+ };const setLoading = (loading: boolean) => {listElement.querySelector('[data-relation-type="loader"]')?.classList.toggle("fn__none", !loading);@@ -455,8 +492,17 @@ ${genRelationLoaderHTML(state.loading)}`;databaseName.setAttribute("data-id", response.data.blockIDs?.[0] || "");renderPage(cells, reset);setLoading(false);- const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();- setPosition(options.menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);+ let listHeightChanged = false;+ if (listNaturalMaxHeight < 1 && (keyword === "" || cells.length === RELATION_PAGE_SIZE)) {+ listNaturalMaxHeight = listElement.scrollHeight;+ if (listNaturalMaxHeight > 0) {+ listHeightChanged = updateListMaxHeight();+ }+ }+ if (!positionInitialized || listHeightChanged) {+ resetPosition();+ }+ positionMenu();succeeded = true;}, undefined, undefined, controller.signal).finally(() => {if (state.controller !== controller) {@@ -530,9 +576,11 @@ ${genRelationLoaderHTML(state.loading)}`;showMessage(window.siyuan.languages.copied);}});+ window.addEventListener("resize", resize);loadPage(true);return () => {state.controller?.abort();+ window.removeEventListener("resize", resize);if (searchTimer) {clearTimeout(searchTimer);}