fix(navigation): resolve clicked anchor when target is a nested element

A click on a child of an <a> (e.g. nested <strong>, <em>, <code>, 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.
This commit is contained in:
Julien Calixte
2026-04-26 13:58:48 +02:00
parent 9f75e7971d
commit 836b480ea6
2 changed files with 4 additions and 4 deletions

View File

@@ -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