File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const props = defineProps<{
1313}>()
1414
1515const depth = computed (() => props .depth ?? 0 )
16+ const treeRoot = useTemplateRef (' treeRoot' )
1617
1718// Check if a node or any of its children is currently selected
1819function isNodeActive(node : PackageFileTree ): boolean {
@@ -37,7 +38,7 @@ function getFileRoute(nodePath: string): RouteLocationRaw {
3738const { toggleDir, isExpanded, autoExpandAncestors } = useFileTreeState (props .baseUrl )
3839
3940const scrollIntoView = () => {
40- const el = document .querySelector (' [aria-current="true"]' ) as HTMLElement
41+ const el = treeRoot . value ? .querySelector (' [aria-current="true"]' ) as HTMLElement
4142 if (el ) {
4243 el .scrollIntoView ({ block: ' center' })
4344 }
5758 </script >
5859
5960<template >
60- <ul class =" list-none m-0 p-0" :class =" depth === 0 ? 'py-2' : ''" >
61+ <ul ref = " treeRoot " class =" list-none m-0 p-0" :class =" depth === 0 ? 'py-2' : ''" >
6162 <li v-for =" node in tree" :key =" node.path" >
6263 <!-- Directory -->
6364 <template v-if =" node .type === ' directory' " >
You can’t perform that action at this time.
0 commit comments