Skip to content

Commit 30a4dce

Browse files
committed
feat: code file tree switch file to active node
1 parent 58da597 commit 30a4dce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/components/Code/FileTree.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ function getFileRoute(nodePath: string): RouteLocationRaw {
3636
3737
const { toggleDir, isExpanded, autoExpandAncestors } = useFileTreeState(props.baseUrl)
3838
39+
const scrollIntoView = () => {
40+
const el = document.querySelector('[aria-current="true"]') as HTMLElement
41+
if (el) {
42+
el.scrollIntoView({ block: 'center' })
43+
}
44+
}
45+
3946
// Auto-expand directories in the current path
4047
watch(
4148
() => props.currentPath,
4249
path => {
4350
if (path) {
4451
autoExpandAncestors(path)
52+
nextTick(scrollIntoView)
4553
}
4654
},
4755
{ immediate: true },

0 commit comments

Comments
 (0)