Skip to content

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

:bug: Prevent document tree jitter during expand and collapse https://github.com/siyuan-note/siyuan/issues/18700

Daniel3997f2e444fb
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index c0888bde65..bd7dab376f 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -1643,9 +1643,7 @@ data-type="navigation-root" data-path="/" data-count="${item.subFileCount || 0}"
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
nextElement = liElement.nextElementSibling;
this.restoreMovedExpandedItems(nextElement, data.box);
- nextElement.setAttribute("style", "top: -1px;position: relative;");
expandFileTree(nextElement as HTMLElement, () => {
- nextElement.removeAttribute("style");
if (typeof scrollTop === "number") {
this.element.scroll({top: scrollTop, behavior: "smooth"});
}
diff --git a/app/src/layout/dock/fileTreeAnimation.test.ts b/app/src/layout/dock/fileTreeAnimation.test.ts
index 567dc22801..fee18ed090 100644
--- a/app/src/layout/dock/fileTreeAnimation.test.ts
+++ b/app/src/layout/dock/fileTreeAnimation.test.ts
@@ -121,7 +121,7 @@ describe("fileTreeAnimation", () => {
assert.deepEqual(tree.getFrames(), [{height: "0"}, {height: "96px"}]);
assert.equal(tree.getOptions().duration, 200);
- assert.equal(tree.leafElement.style.overflow, "hidden");
+ assert.equal(tree.leafElement.style.overflow, "clip");
tree.animation.finish();
await tree.animation.animation.finished;
@@ -148,6 +148,7 @@ describe("fileTreeAnimation", () => {
assert.equal(tree.isArrowClosed(), true);
assert.equal(isFileTreeCollapsing(tree.liElement), true);
assert.deepEqual(tree.getFrames(), [{height: "96px"}, {height: "0"}]);
+ assert.equal(tree.leafElement.style.overflow, "clip");
tree.animation.finish();
await tree.animation.animation.finished;
diff --git a/app/src/layout/dock/fileTreeAnimation.ts b/app/src/layout/dock/fileTreeAnimation.ts
index d39df301c8..af30239a40 100644
--- a/app/src/layout/dock/fileTreeAnimation.ts
+++ b/app/src/layout/dock/fileTreeAnimation.ts
@@ -9,7 +9,7 @@ const getAnimationOptions = (): KeyframeAnimationOptions => ({
});
export const expandFileTree = (element: HTMLElement, onFinish?: () => void) => {
- element.style.overflow = "hidden";
+ element.style.overflow = "clip";
const animation = element.animate([
{height: "0"},
{height: `${element.scrollHeight}px`},
@@ -61,7 +61,7 @@ export const collapseFileTree = (liElement: Element, onFinish: () => void) => {
return;
}
- leafElement.style.overflow = "hidden";
+ leafElement.style.overflow = "clip";
const animation = leafElement.animate([
{height: `${leafElement.scrollHeight}px`},
{height: "0"},