From 5708613d2e1851ca77d14e38d8f8b94427d27d02 Mon Sep 17 00:00:00 2001 From: Gaurav Jadhav Date: Tue, 25 Aug 2026 15:05:50 +0530 Subject: [PATCH] fix(editor): prevent duplicate tab when clicking links in read-only view The custom link extension's click handler calls window.open() but never calls event.preventDefault(). In an editable view ProseMirror suppresses the native anchor click (contenteditable), so only window.open() fires. In a read-only view that suppression doesn't happen, so the native navigation also fires, opening a second identical tab. Fixes #9386 --- .../src/core/extensions/custom-link/helpers/clickHandler.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts b/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts index 98c795cea3d..1cb5fe5612b 100644 --- a/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts +++ b/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts @@ -50,6 +50,11 @@ export function clickHandler(options: ClickHandlerOptions): Plugin { return false; } + // Suppress the native anchor navigation: in a non-editable view + // ProseMirror doesn't swallow the click, so without this the + // browser opens a second tab via the underlying + // in addition to the one below (#9386). + event.preventDefault(); window.open(href, target); return true;