From 674adb48ba58d46ee089980266a9060fe2f5f23b Mon Sep 17 00:00:00 2001 From: userquin Date: Sun, 8 Jan 2023 18:42:06 +0100 Subject: [PATCH] chore: prevent scroll on tabs and side nav --- components/common/CommonRouteTabs.vue | 2 +- components/nav/NavSideItem.vue | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/common/CommonRouteTabs.vue b/components/common/CommonRouteTabs.vue index dc2850e5..8b65cdaf 100644 --- a/components/common/CommonRouteTabs.vue +++ b/components/common/CommonRouteTabs.vue @@ -50,7 +50,7 @@ const handleClick = (to: RouteLocationRaw) => { tabindex="1" hover:bg-active transition-100 exact-active-class="children:(text-secondary !border-primary !op100 !text-base)" - @click="handleClick(option.to)" + @click.capture="handleClick(option.to)" > {{ option.display }} diff --git a/components/nav/NavSideItem.vue b/components/nav/NavSideItem.vue index aa9c9243..eea8d470 100644 --- a/components/nav/NavSideItem.vue +++ b/components/nav/NavSideItem.vue @@ -15,6 +15,7 @@ defineSlots<{ }>() const router = useRouter() +const nuxtApp = useNuxtApp() useCommand({ scope: 'Navigation', @@ -41,6 +42,13 @@ onMastoInit(async () => { // when we know there is no user. const noUserDisable = computed(() => !isMastoInitialised.value || (props.userOnly && !currentUser.value)) const noUserVisual = computed(() => isMastoInitialised.value && props.userOnly && !currentUser.value) + +const handleClick = () => { + if (nuxtApp.$preventScrollToTop(router.resolve(props.to).fullPath)) + return + + nuxtApp.$scrollToTop() +}