From 836b480ea65fb2851c56474e48860bf8190d0e2c Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 26 Apr 2026 13:58:48 +0200 Subject: [PATCH] fix(navigation): resolve clicked anchor when target is a nested element A click on a child of an (e.g. nested , , , icon) made event.target a non-anchor, so getAttribute('href') returned null and the handler bailed without preventDefault. The browser then performed the native navigation, which for relative links like '../note.md' resolved against the current /:user/:repo URL and the SPA re-routed treating the destination as a new repo. --- src/hooks/useATProtoLinks.hook.ts | 4 ++-- src/hooks/useLinks.hook.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hooks/useATProtoLinks.hook.ts b/src/hooks/useATProtoLinks.hook.ts index 50278ec..6fcad04 100644 --- a/src/hooks/useATProtoLinks.hook.ts +++ b/src/hooks/useATProtoLinks.hook.ts @@ -17,8 +17,8 @@ export const useATProtoLinks = ( const { currentAtUri, mainNoteId } = options const linkNote = (event: Event) => { - const target = event.target as HTMLElement - const href = target.getAttribute("href") + const anchor = (event.target as HTMLElement).closest("a") + const href = anchor?.getAttribute("href") if (!href) { return diff --git a/src/hooks/useLinks.hook.ts b/src/hooks/useLinks.hook.ts index f099965..c837fb9 100644 --- a/src/hooks/useLinks.hook.ts +++ b/src/hooks/useLinks.hook.ts @@ -11,8 +11,8 @@ export const useLinks = ( const store = useUserRepoStore() const linkNote: EventListener = (event) => { - const target = event.target as HTMLElement - const href = target.getAttribute("href") + const anchor = (event.target as HTMLElement).closest("a") + const href = anchor?.getAttribute("href") if (!href) { return