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(settings): reset scroll on tab switch

zipg0edba2f02345
diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
index 073920c4e7..36c7f02b5d 100644
--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue
+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
@@ -1337,6 +1337,7 @@ function setSidebarActivation(value: "single" | "double") {
}
const activeSettingsTab = ref("appearance");
+const settingsContentScrollRef = ref<HTMLElement | null>(null);
const isWeb = !isTauriRuntime();
const appSupportInfo = ref<AppSupportInfo | null>(null);
const appSupportInfoLoading = ref(false);
@@ -1382,6 +1383,12 @@ function settingsCategoryButton(value: SettingsCategory): string {
].join(" ");
}
+async function resetSettingsContentScroll() {
+ await nextTick();
+ const scroller = settingsContentScrollRef.value;
+ if (scroller) scroller.scrollTop = 0;
+}
+
function openExternalUrl(url: string) {
if (isTauriRuntime()) {
import("@tauri-apps/plugin-shell").then(({ open }) => open(url));
@@ -2024,6 +2031,7 @@ watch(snippetProvider, (provider) => {
});
watch(activeSettingsTab, async (tab) => {
+ void resetSettingsContentScroll();
if (tab === "mcp" && !mcpStatus.value && !mcpStatusLoading.value) void refreshMcpStatus();
if (tab === "ai" && aiIsCliProvider.value) void ensureCliMcpStatus();
if (tab === "ai") {
@@ -3130,7 +3138,7 @@ onUnmounted(cleanupPreviewEditor);
</nav>
<div class="min-w-0 flex-1 overflow-hidden px-1 flex flex-col">
- <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-1 pr-2">
+ <div ref="settingsContentScrollRef" class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-1 pr-2">
<section v-if="activeSettingsTab === 'editor'" class="flex flex-col gap-5 py-2">
<div class="grid gap-4 md:grid-cols-[1fr_auto]">
<!-- Font Family -->
diff --git a/packages/app-tests/settingsStore.test.ts b/packages/app-tests/settingsStore.test.ts
index c59a47b49a..8b57131562 100644
--- a/packages/app-tests/settingsStore.test.ts
+++ b/packages/app-tests/settingsStore.test.ts
@@ -617,6 +617,16 @@ test("shows persisted UI scales that are not available as presets", () => {
assert.match(source, /<SelectValue>\{\{ Math\.round\(editUiScale \* 100\) \}\}%<\/SelectValue>/);
});
+test("settings page resets content scroll when switching categories", () => {
+ const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
+
+ assert.match(source, /const settingsContentScrollRef = ref<HTMLElement \| null>\(null\)/);
+ assert.match(source, /function resetSettingsContentScroll\(\)/);
+ assert.match(source, /if \(scroller\) scroller\.scrollTop = 0/);
+ assert.match(source, /watch\(activeSettingsTab, async \(tab\) => \{\s+void resetSettingsContentScroll\(\);/);
+ assert.match(source, /ref="settingsContentScrollRef" class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden/);
+});
+
test("defaults SQL formatter settings", () => {
assert.deepEqual(DEFAULT_EDITOR_SETTINGS.sqlFormatter, DEFAULT_SQL_FORMATTER_SETTINGS);
assert.deepEqual(normalizeEditorSettings({}).sqlFormatter, DEFAULT_EDITOR_SETTINGS.sqlFormatter);