Skip to content

Build your personal knowledge base with Trilium Notes

fix(launch_bar): some context menus intercepted by browser

Elian Doran8ec6125ec47f
diff --git a/apps/client/src/widgets/launch_bar/GenericButtons.tsx b/apps/client/src/widgets/launch_bar/GenericButtons.tsx
index ba29b303b5..6933233a66 100644
--- a/apps/client/src/widgets/launch_bar/GenericButtons.tsx
+++ b/apps/client/src/widgets/launch_bar/GenericButtons.tsx
@@ -32,6 +32,9 @@ export function CustomNoteLauncher(props: {
onClick={launch}
onAuxClick={launch}
onContextMenu={async evt => {
+ // Must preventDefault synchronously — awaiting getTargetNoteId first would let the
+ // native browser context menu open before showLauncherContextMenu gets a chance to.
+ evt.preventDefault();
const targetNoteId = await getTargetNoteId(launcherNote);
const hoistedNoteId = getHoistedNoteId?.(launcherNote) ?? null;
const linkItems = targetNoteId ? link_context_menu.getItems(evt) : [];
diff --git a/apps/client/src/widgets/launch_bar/HistoryNavigation.tsx b/apps/client/src/widgets/launch_bar/HistoryNavigation.tsx
index 11ad476312..b35e38f337 100644
--- a/apps/client/src/widgets/launch_bar/HistoryNavigation.tsx
+++ b/apps/client/src/widgets/launch_bar/HistoryNavigation.tsx
@@ -27,6 +27,8 @@ export default function HistoryNavigationButton({ launcherNote, command }: Histo
text={title}
triggerCommand={command}
onContextMenu={async (e) => {
+ // Prevent the native menu synchronously before awaiting history items.
+ e.preventDefault();
const items = webContents ? await getHistoryItems(webContents) : [];
showLauncherContextMenu<string>(launcherNote, e, {
extraItems: items,