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(null); const isWeb = !isTauriRuntime(); const appSupportInfo = ref(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);
-
+
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, /\{\{ 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\(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);