Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/5127 3

Vanessa5981e7811691
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index 64b02acc2e..2d7fce99d4 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -226,11 +226,12 @@ export class Outline extends Model {
}
if (currentElement) {
currentElement.classList.add("b3-list-item--focus");
- const titleHeight = this.headerElement.clientHeight;
- if (currentElement.offsetTop - titleHeight < this.element.scrollTop) {
- this.element.scrollTop = currentElement.offsetTop - titleHeight;
- } else if (currentElement.offsetTop - this.element.clientHeight - titleHeight + currentElement.clientHeight > this.element.scrollTop) {
- this.element.scrollTop = currentElement.offsetTop - this.element.clientHeight - titleHeight + currentElement.clientHeight;
+ const currentRect = currentElement.getBoundingClientRect()
+ const scrollRect = this.element.getBoundingClientRect()
+ if (currentRect.top < scrollRect.top) {
+ currentElement.scrollIntoView();
+ } else if (currentRect.bottom > scrollRect.bottom) {
+ currentElement.scrollIntoView(false);
}
}
}