diff --git a/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue b/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue index cf842baa3..7e00b1ec7 100644 --- a/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue +++ b/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue @@ -4,7 +4,7 @@ import { onContentUpdated } from 'vitepress' import type { DefaultTheme } from 'vitepress/theme' import { nextTick, ref, watch } from 'vue' import { useData } from '../composables/data' -import { resolveTitle } from '../composables/outline' +import { resolveTitle, useFloatActiveAnchor } from '../composables/outline' import VPDocOutlineItem from './VPDocOutlineItem.vue' const props = defineProps<{ @@ -17,6 +17,7 @@ const open = ref(false) const vh = ref(0) const main = ref() const items = ref() +const marker = ref() function closeOnClickOutside(e: Event) { if (!main.value?.contains(e.target as Node)) { @@ -61,6 +62,8 @@ function scrollToTop() { open.value = false window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }) } + +useFloatActiveAnchor(items, marker, open)