mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-25 02:36:21 +03:00
chore: restore nav side item click state
This commit is contained in:
parent
db2140e350
commit
6dde98eb78
1 changed files with 20 additions and 1 deletions
|
@ -14,8 +14,27 @@ defineSlots<{
|
|||
default: {}
|
||||
}>()
|
||||
|
||||
const nuxtApp = useNuxtApp()
|
||||
const router = useRouter()
|
||||
|
||||
const allowScrollTop = ref(false)
|
||||
|
||||
const restoreClickHook = () => {
|
||||
if (isHydrated.value) {
|
||||
if (typeof props.to === 'string')
|
||||
allowScrollTop.value = router.currentRoute.value.fullPath === props.to
|
||||
else
|
||||
allowScrollTop.value = router.currentRoute.value.name === props.to.name
|
||||
}
|
||||
}
|
||||
|
||||
router.afterEach(() => {
|
||||
allowScrollTop.value = false
|
||||
})
|
||||
|
||||
nuxtApp.hooks.hook('app:suspense:resolve', restoreClickHook)
|
||||
nuxtApp.hooks.hook('page:finish', restoreClickHook)
|
||||
|
||||
useCommand({
|
||||
scope: 'Navigation',
|
||||
|
||||
|
@ -51,7 +70,7 @@ const noUserVisual = computed(() => isHydrated.value && props.userOnly && !curre
|
|||
:active-class="activeClass"
|
||||
group focus:outline-none disabled:pointer-events-none
|
||||
:tabindex="noUserDisable ? -1 : null"
|
||||
@click="$trackScroll.forceScrollToTop()"
|
||||
@click="allowScrollTop && $trackScroll.forceScrollToTop()"
|
||||
>
|
||||
<CommonTooltip :disabled="!isMediumOrLargeScreen" :content="text" placement="right">
|
||||
<div
|
||||
|
|
Loading…
Reference in a new issue