fix(settings): reset scroll on tab switch
This commit is contained in:
@@ -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 -->
|
||||
|
||||
+10
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user