mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-28 21:38:52 +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: {}
|
default: {}
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const nuxtApp = useNuxtApp()
|
||||||
const router = useRouter()
|
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({
|
useCommand({
|
||||||
scope: 'Navigation',
|
scope: 'Navigation',
|
||||||
|
|
||||||
|
@ -51,7 +70,7 @@ const noUserVisual = computed(() => isHydrated.value && props.userOnly && !curre
|
||||||
:active-class="activeClass"
|
:active-class="activeClass"
|
||||||
group focus:outline-none disabled:pointer-events-none
|
group focus:outline-none disabled:pointer-events-none
|
||||||
:tabindex="noUserDisable ? -1 : null"
|
:tabindex="noUserDisable ? -1 : null"
|
||||||
@click="$trackScroll.forceScrollToTop()"
|
@click="allowScrollTop && $trackScroll.forceScrollToTop()"
|
||||||
>
|
>
|
||||||
<CommonTooltip :disabled="!isMediumOrLargeScreen" :content="text" placement="right">
|
<CommonTooltip :disabled="!isMediumOrLargeScreen" :content="text" placement="right">
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Reference in a new issue