From 6e67832416cbb18a51b5a7ac7a5b6a246716b9bc Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 6 Jun 2025 23:59:43 +0300 Subject: [PATCH] fix(client): clicking on note list not working due to anchor management --- apps/client/src/services/link.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 22a33000d..62a5a46ab 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -286,7 +286,9 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent evt.stopPropagation(); if (hrefLink && hrefLink.startsWith("#") && !hrefLink.startsWith("#root/") && $link) { - return handleAnchor(hrefLink, $link); + if (handleAnchor(hrefLink, $link)) { + return true; + } } const { notePath, viewScope } = parseNavigationStateFromUrl(hrefLink); @@ -353,14 +355,14 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent * * @param hrefLink the URL of the link that was clicked (it should be in the form of `#fn` or `#fnref`). * @param $link the element of the link that was clicked. - * @returns whether the event should be consumed or not. + * @returns `true` if the link was handled (i.e., the element was found and scrolled to), `false` otherwise. */ function handleAnchor(hrefLink: string, $link: JQuery) { const el = $link.closest(".ck-content").find(hrefLink)[0]; if (el) { el.scrollIntoView({ behavior: "smooth", block: "center" }); } - return true; + return !!el; } function linkContextMenu(e: PointerEvent) {