From fbe4f7840751e35fef7b4ee9748c6f22d99d343e Mon Sep 17 00:00:00 2001 From: aaandreeew <114206308+aaandreeew@users.noreply.github.com> Date: Wed, 1 Apr 2026 03:03:12 +1000 Subject: [PATCH] Prevent links opening twice in new tab in reading view Fixes issue where ctrl+click or middle-click on a link while in reading view would cause the link to be opened twice in two new tabs. --- main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.ts b/main.ts index 504d3f0..291c51f 100644 --- a/main.ts +++ b/main.ts @@ -1740,6 +1740,9 @@ export default class VirtualFooterPlugin extends Plugin { * @param component The Obsidian Component associated with this content, for event registration. */ public attachInternalLinkHandlers(container: HTMLElement, sourcePath: string, component: Component): void { + // If in reading view, do nothing, as the default behavior is fine + if (container.closest(".markdown-reading-view")) return; + // Handle left-click on internal links and external file links component.registerDomEvent(container, 'click', (event: MouseEvent) => { if (event.button !== 0) return; // Only handle left-clicks