Skip to content

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

refactor setCurrent func scroll policy (#14265)

sommermorgentraumc1b01b7fbdd9
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 2f82c9da6f..942afe0963 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -1108,13 +1108,14 @@ data-type="navigation-root" data-path="/">
liItem.classList.remove("b3-list-item--focus");
});
target.classList.add("b3-list-item--focus");
+
if (isScroll) {
- let offsetTop = target.offsetTop;
- // https://github.com/siyuan-note/siyuan/issues/8749
- if (target.parentElement.classList.contains("file-tree__sliderDown") && target.offsetParent) {
- offsetTop = (target.offsetParent as HTMLElement).offsetTop;
- }
- this.element.scrollTop = offsetTop - this.element.clientHeight / 2 - this.actionsElement.clientHeight;
+ const targetRect = target.getBoundingClientRect();
+ const containerRect = this.element.getBoundingClientRect();
+
+ const relativeTop = targetRect.top - containerRect.top + this.element.scrollTop;
+
+ this.element.scrollTop = relativeTop - this.element.clientHeight / 2 - this.actionsElement.clientHeight;
}
}