Skip to content

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

:bug: Reposition menus after mobile keyboard resize

Daniel4f70d08b6e27
diff --git a/app/src/config/tabs/ai/aiProviderUi.ts b/app/src/config/tabs/ai/aiProviderUi.ts
index d604367935..fc99c2e2ee 100644
--- a/app/src/config/tabs/ai/aiProviderUi.ts
+++ b/app/src/config/tabs/ai/aiProviderUi.ts
@@ -356,7 +356,7 @@ const openAvailableModelMenu = (modelInput: HTMLInputElement, models: string[])
},
});
const rect = modelInput.getBoundingClientRect();
- menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width});
+ menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width, target: modelInput});
menu.element.querySelector(".b3-menu__items").setAttribute("style", "overflow: initial");
menu.element.querySelector<HTMLInputElement>("input").focus();
};
@@ -909,7 +909,7 @@ const openGroupedModelMenu = (
});
const rect = element.getBoundingClientRect();
menu.element.style.minWidth = `${rect.width}px`;
- menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width});
+ menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width, target: element});
};
const syncGroupedModelPickers = (root: HTMLElement) => {
diff --git a/app/src/layout/dock/agent/AgentChat.ts b/app/src/layout/dock/agent/AgentChat.ts
index 7deeb05856..4396be4ca9 100644
--- a/app/src/layout/dock/agent/AgentChat.ts
+++ b/app/src/layout/dock/agent/AgentChat.ts
@@ -589,7 +589,7 @@ export class AgentChat extends Model {
});
const rect = this.permissionButton.getBoundingClientRect();
menu.element.style.minWidth = `${rect.width}px`;
- menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width});
+ menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width, target: this.permissionButton});
});
}
@@ -620,7 +620,7 @@ export class AgentChat extends Model {
});
const rect = this.reasoningEffortButton.getBoundingClientRect();
menu.element.style.minWidth = `${Math.max(rect.width, 120)}px`;
- menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width});
+ menu.open({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width, target: this.reasoningEffortButton});
});
}
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 9a3e318ba4..6eb7a794b3 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -514,6 +514,13 @@ export class Menu {
if (this.element.classList.contains("fn__none")) {
return;
}
+ if (this.position.target?.isConnected) {
+ const rect = this.position.target.getBoundingClientRect();
+ this.position.x = this.position.isLeft ? rect.right : rect.left;
+ this.position.y = rect.bottom;
+ this.position.h = rect.height;
+ this.position.w = rect.width;
+ }
setPosition(this.element, this.position.x - (this.position.isLeft ? this.element.clientWidth : 0), this.position.y, this.position.h, this.position.w);
this.updateMaxHeight(this.element, this.element.lastElementChild as HTMLElement);
this.element.querySelectorAll(".b3-menu__item--show .b3-menu__submenu").forEach((item: HTMLElement) => {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 516bd235c3..b8df626728 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -402,7 +402,8 @@ interface IPosition {
y: number,
w?: number,
h?: number,
- isLeft?: boolean
+ isLeft?: boolean,
+ target?: HTMLElement
}
interface ISaveLayout {