Skip to content

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

Refactor setCurrentById of Outline func scroll policy (#14312)

sommermorgentraumaedbd6bee86d
diff --git a/.gitignore b/.gitignore
index bc40458008..1ceb3fe86f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ app/stage/build
app/build
app/src/types/dist
app/kernel*
+app/SiYuan-Kernel
ios
pprof
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index b1afbe83ad..7c3472f6d4 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -485,7 +485,12 @@ export class Outline extends Model {
}
if (currentElement) {
currentElement.classList.add("b3-list-item--focus");
- this.element.scrollTop = currentElement.offsetTop - this.element.clientHeight / 2 - 30;
+
+ const targetRect = currentElement.getBoundingClientRect();
+ const containerRect = this.element.getBoundingClientRect();
+ const relativeTop = targetRect.top - containerRect.top + this.element.scrollTop;
+
+ this.element.scrollTop = relativeTop - this.element.clientHeight / 2 - 30;
}
}