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: Preserve mind map expansion animations across resize notifications https://github.com/siyuan-note/siyuan/issues/20800
Danieldef427da9a80
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex e979113815..039eb58332 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -3148,6 +3148,13 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,check.equal(foldedButton.querySelector("span").textContent, String(model.nodes.size - 1));check.equal(getComputedStyle(foldedButton).visibility, "visible");foldedButton.click();+ await settle();+ if (!window.matchMedia("(prefers-reduced-motion: reduce)").matches) {+ check.ok(readonly.stopFoldAnimation,+ "showing folded children must not let size observers end the expansion early");+ check.ok(Number(nodeElement(alpha).style.opacity) > 0 && Number(nodeElement(alpha).style.opacity) < 1,+ "newly visible children retain an intermediate expansion frame after size notifications");+ }await settleFold(readonly);check.equal(nodeElement(alpha).hidden, false);const afterExpand = nodeElement(model.root.id).getBoundingClientRect();@@ -3161,6 +3168,19 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,check.equal(nodeElement(alpha).hidden, false, "rapid fold reversals finish in the latest requested state");check.equal(nodeElement(alpha).style.opacity, "");check.equal(nodeElement(alpha).inert, false);+ foldedButton.click();+ await settleFold(readonly);+ foldedButton.click();+ await settle();+ const measuredWidth = nodeElement(alpha).offsetWidth;+ nodeElement(alpha).style.minWidth = `${measuredWidth + 40}px`;+ await settle();+ check.equal(readonly.stopFoldAnimation, undefined,+ "a genuine node size change still ends the transition and lays out its new dimensions");+ check.equal(readonly.positions.get(alpha).width, nodeElement(alpha).offsetWidth);+ check.ok(readonly.positions.get(alpha).width > measuredWidth);+ nodeElement(alpha).style.minWidth = "";+ await settle();const levelSelect = host.querySelector<HTMLSelectElement>(".mindmap-view__level-select");check.deepEqual(Array.from(levelSelect.options).map(option => option.value),["", "expandAll", "foldAll", "1", "2", "3", "4", "5", "6"]);diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex 44c1a8f2fb..8a4758b0b8 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -368,9 +368,22 @@ export class ListMindmapView {}}});- this.resizeObserver = new ResizeObserver(() => {+ this.resizeObserver = new ResizeObserver(entries => {this.updateToolbarLayout();- this.refreshLayout();+ // 展开会让隐藏节点恢复尺寸;布局已测量这些节点,不应被同一尺寸的通知中断动画。+ const resized = !this.stopFoldAnimation || entries.some(({target}) => {+ if (target === this.viewport) {+ return true;+ }+ const element = target as HTMLElement;+ const position = this.positions.get(element.dataset.mindmapId) ||+ this.summaryPositions.get(element.dataset.summaryId);+ return !element.hidden && position &&+ (element.offsetWidth !== position.width || element.offsetHeight !== position.height);+ });+ if (resized) {+ this.refreshLayout();+ }this.positionInspectorPanel();});this.resizeObserver.observe(this.viewport);