Skip to content

Commit 8ccd8bd

Browse files
committed
Scroll to last folder when going up
1 parent a45b0f1 commit 8ccd8bd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/lib/file-explorer/FilePane.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { onMount, untrack } from 'svelte'
2+
import { onMount, tick, untrack } from 'svelte'
33
import type { FileEntry } from './types'
44
import { openFile } from '$lib/tauri-commands'
55
import FileList from './FileList.svelte'
@@ -111,6 +111,12 @@
111111
const visibleFiles = filterFiles(firstChunk, showHiddenFiles)
112112
const targetIndex = visibleFiles.findIndex((f) => f.name === selectName)
113113
selectedIndex = targetIndex >= 0 ? targetIndex : 0
114+
115+
// Scroll the selected folder into view (after DOM updates)
116+
void tick().then(() => {
117+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
118+
fileListRef?.scrollToIndex(selectedIndex)
119+
})
114120
} else {
115121
selectedIndex = 0
116122
}

0 commit comments

Comments
 (0)