From 4b1142d688b58dea00106e24176f5965a3ad6329 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 3 Apr 2021 23:16:18 +0200 Subject: [PATCH] :bug: (breadcrump) back to home on click --- src/components/FluxNote.vue | 2 +- src/hooks/useFocus.hook.ts | 7 ++++++- src/hooks/useLinks.hook.ts | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/FluxNote.vue b/src/components/FluxNote.vue index 74bb8b5..2c2b268 100644 --- a/src/components/FluxNote.vue +++ b/src/components/FluxNote.vue @@ -115,7 +115,7 @@ export default defineComponent({ stackedNotes, resetStackedNotes, userSettings: computed(() => store.userSettings), - focus: () => scrollToFocusedNote(), + focus: () => scrollToFocusedNote(undefined, true), ...noteProps } } diff --git a/src/hooks/useFocus.hook.ts b/src/hooks/useFocus.hook.ts index 9c93bf1..f31df64 100644 --- a/src/hooks/useFocus.hook.ts +++ b/src/hooks/useFocus.hook.ts @@ -9,11 +9,16 @@ export const useFocus = () => { const { scrollToNote, isMobile } = useOverlay(false) const { stackedNotes } = useQueryStackedNotes() - const scrollToFocusedNote = (sha?: string) => { + const scrollToFocusedNote = (sha?: string, backToTop?: boolean) => { if (!sha) { return } + if (backToTop) { + scrollToNote(0) + return + } + nextTick(() => { const index = stackedNotes.value.findIndex((noteSHA) => noteSHA === sha) diff --git a/src/hooks/useLinks.hook.ts b/src/hooks/useLinks.hook.ts index 5322473..6109cec 100644 --- a/src/hooks/useLinks.hook.ts +++ b/src/hooks/useLinks.hook.ts @@ -12,6 +12,8 @@ export const useLinks = (className: string, sha?: string) => { const target = event.target as HTMLElement const href = target.getAttribute('href') + console.log(target, href) + if (!href) { return }