Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(editor): restore focus after query tab switches

二丫讲梵0ec7bef0987c
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index aeeee11299..cce624676f 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -6730,6 +6730,7 @@ watch([() => props.tabId, () => props.modelValue], ([tabId, val], [prevTabId]) =
if (!view.value) return;
if (tabId !== prevTabId) {
activateTabDocument(prevTabId, tabId, val);
+ if (props.autoFocus) restoreEditorFocus();
return;
}
if (val !== view.value.state.doc.toString()) {
diff --git a/apps/desktop/src/lib/__tests__/editor/queryEditorFocus.spec.ts b/apps/desktop/src/lib/__tests__/editor/queryEditorFocus.spec.ts
index 3fa2a307ae..38b777f063 100644
--- a/apps/desktop/src/lib/__tests__/editor/queryEditorFocus.spec.ts
+++ b/apps/desktop/src/lib/__tests__/editor/queryEditorFocus.spec.ts
@@ -47,6 +47,10 @@ describe("QueryEditor auto focus wiring", () => {
it("enables auto focus for query tabs", () => {
expect(contentAreaSource).toMatch(/<QueryEditor[\s\S]*?:\s*auto-focus="autoFocus !== false"\s[\s\S]*?:model-value="activeTab\.sql"/);
});
+
+ it("restores focus when the active query tab changes", () => {
+ expect(queryEditorSource).toMatch(/if \(tabId !== prevTabId\) \{[\s\S]*?activateTabDocument\(prevTabId, tabId, val\);[\s\S]*?if \(props\.autoFocus\) restoreEditorFocus\(\);/);
+ });
});
describe("QueryEditor toolbar focus", () => {