Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): keep dialog open when double-clicking contained links

Elian Dorand237b61364d8
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 9c051fe29d..ac1995e4f1 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -1850,11 +1850,21 @@ export function useContainedLinkNavigation(
e.preventDefault();
e.stopPropagation();
- onNavigate(notePath, viewScope);
+ // A double-click also fires a separate `dblclick` event that the global handler in
+ // link.ts treats as "open in a new tab", which would navigate away and dismiss the
+ // surrounding dialog. The preceding `click` already navigated, so for `dblclick` we
+ // only need to swallow the event and skip the redundant navigation.
+ if (e.type !== "dblclick") {
+ onNavigate(notePath, viewScope);
+ }
}
container.addEventListener("click", onClick, true);
- return () => container.removeEventListener("click", onClick, true);
+ container.addEventListener("dblclick", onClick, true);
+ return () => {
+ container.removeEventListener("click", onClick, true);
+ container.removeEventListener("dblclick", onClick, true);
+ };
}, [ containerRef, onNavigate ]);
}