Skip to content

Commit ab14372

Browse files
committed
fix: apply review
1 parent 30a4dce commit ab14372

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/components/Code/FileTree.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const props = defineProps<{
1313
}>()
1414
1515
const depth = computed(() => props.depth ?? 0)
16+
const treeRoot = useTemplateRef('treeRoot')
1617
1718
// Check if a node or any of its children is currently selected
1819
function isNodeActive(node: PackageFileTree): boolean {
@@ -37,7 +38,7 @@ function getFileRoute(nodePath: string): RouteLocationRaw {
3738
const { toggleDir, isExpanded, autoExpandAncestors } = useFileTreeState(props.baseUrl)
3839
3940
const 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
}
@@ -57,7 +58,7 @@ watch(
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'">

0 commit comments

Comments
 (0)