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: Keep anchored menus aligned during keyboard transitions
Daniel67312459e6a4
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.tsindex 6eb7a794b3..e32a9138aa 100644--- a/app/src/menus/Menu.ts+++ b/app/src/menus/Menu.ts@@ -66,6 +66,17 @@ export class Menu {private sheetCanDrag = false;private sheetDragging = false;private suppressSheetClick = false;+ private targetPositionFrame: number | undefined;++ private updateTargetPosition = () => {+ if (typeof this.targetPositionFrame === "number") {+ cancelAnimationFrame(this.targetPositionFrame);+ }+ this.targetPositionFrame = requestAnimationFrame(() => {+ this.targetPositionFrame = undefined;+ this.resetPosition();+ });+ };constructor(element?: HTMLElement) {this.wheelEvent = "onwheel" in document.createElement("div") ? "wheel" : "mousewheel";@@ -459,6 +470,7 @@ export class Menu {clearTimeout(fullscreenCloseTimeout);this.hideFullscreenScrim();this.finishSheetTouch();+ this.stopTrackingTargetPosition();if (this.removeCB) {const removeCB = this.removeCB;this.removeCB = undefined;@@ -505,13 +517,14 @@ export class Menu {window.addEventListener(isMobile() ? "touchmove" : this.wheelEvent, this.preventDefault, {passive: false});this.element.style.zIndex = (++window.siyuan.zIndex).toString();this.element.classList.remove("fn__none");+ this.position = options;setPosition(this.element, options.x - (options.isLeft ? this.element.clientWidth : 0), options.y, options.h, options.w);this.updateMaxHeight(this.element, this.element.lastElementChild as HTMLElement);- this.position = options;+ this.startTrackingTargetPosition();}public resetPosition() {- if (this.element.classList.contains("fn__none")) {+ if (this.element.classList.contains("fn__none") || !this.position) {return;}if (this.position.target?.isConnected) {@@ -529,6 +542,26 @@ export class Menu {});}+ private startTrackingTargetPosition() {+ this.stopTrackingTargetPosition();+ if (!this.position.target) {+ return;+ }+ window.addEventListener("resize", this.updateTargetPosition);+ window.visualViewport?.addEventListener("resize", this.updateTargetPosition);+ window.visualViewport?.addEventListener("scroll", this.updateTargetPosition);+ }++ private stopTrackingTargetPosition() {+ window.removeEventListener("resize", this.updateTargetPosition);+ window.visualViewport?.removeEventListener("resize", this.updateTargetPosition);+ window.visualViewport?.removeEventListener("scroll", this.updateTargetPosition);+ if (typeof this.targetPositionFrame === "number") {+ cancelAnimationFrame(this.targetPositionFrame);+ this.targetPositionFrame = undefined;+ }+ }+public fullscreen(position: "bottom" | "all" = "all") {applyMenuConfig(this.element);if (this.element.lastElementChild.innerHTML === "") {