Skip to content

fix(editor): prevent duplicate tab when clicking links in read-only view - #9681

Open
jadhavgaurav wants to merge 1 commit into
makeplane:previewfrom
jadhavgaurav:fix/duplicate-tab-on-readonly-link-click
Open

fix(editor): prevent duplicate tab when clicking links in read-only view#9681
jadhavgaurav wants to merge 1 commit into
makeplane:previewfrom
jadhavgaurav:fix/duplicate-tab-on-readonly-link-click

Conversation

@jadhavgaurav

@jadhavgaurav jadhavgaurav commented Aug 25, 2026

Copy link
Copy Markdown

Summary

Left-clicking a link inside a read-only rendered comment or work-item
description (e.g. a PR URL) opens it in two identical tabs instead of one.
Editable mode is unaffected.

Root cause

clickHandler.ts's ProseMirror click handler calls window.open(href, target)
but never calls event.preventDefault(). In an editable view, ProseMirror
suppresses the native anchor click (the editor is contenteditable), so only
window.open() fires. In a read-only view that suppression doesn't
happen, so the native <a target="_blank"> navigation also fires — one tab
from window.open(), a second from the browser following the anchor itself.

Fix

Call event.preventDefault() before window.open(), so the native anchor
navigation is suppressed in both editable and read-only modes. One line.

Tests

packages/editor currently has no test runner configured (no test script,
no vitest/jest dependency — unlike apps/live/packages/codemods, which do
have vitest set up). Adding a test harness to this package is out of scope
for a one-line fix, so I didn't bootstrap one. I verified by tracing the
exact code path: event.button !== 0 already short-circuits non-left-clicks
(explaining why middle-click already worked), and the added
preventDefault() sits in the only branch that calls window.open(), before
the return that lets the click bubble.

  • oxlint on the changed file — clean.
  • oxfmt --check on the changed file — clean.
  • pnpm check:types in packages/editor — no new errors introduced (the
    package currently fails to type-check on a clean checkout too, with
    unrelated @plane/utils/@plane/types/etc. "cannot find module" errors
    from unbuilt workspace packages; confirmed identical with and without this
    change via git stash).

Related issue

Fixes #9386

Summary by CodeRabbit

  • Bug Fixes
    • Prevented duplicate navigation when opening links, including links configured to open in a new tab.

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
<a target="_blank"> navigation also fires, opening a second identical tab.

Fixes makeplane#9386
@CLAassistant

CLAassistant commented Aug 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d65db04-dadb-4e7e-8de8-434d6f30cde1

📥 Commits

Reviewing files that changed from the base of the PR and between 1d0ee24 and 5708613.

📒 Files selected for processing (1)
  • packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The custom link click handler now prevents native anchor navigation before calling window.open, so left-clicking links opens one destination instead of triggering duplicate navigation.

Changes

Custom link navigation

Layer / File(s) Summary
Prevent duplicate link opening
packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts
The click handler calls event.preventDefault() before window.open for resolved links.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 57086

This localized change prevents read-only links from opening duplicate tabs by suppressing the browser’s second navigation, with no actionable merge-blocking risk remaining beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the editor bug fix: preventing duplicate tabs for links clicked in read-only view.
Description check ✅ Passed The description explains the issue, root cause, fix, test limitations, validation steps, and linked issue. It omits the template headings for Type of Change and Screenshots, but the required technical…
Linked Issues check ✅ Passed The change meets issue #9386 by calling event.preventDefault() before window.open() for left-click link handling. This prevents native navigation from opening a second tab and leaves non-left-click be…
Out of Scope Changes check ✅ Passed The pull request changes only the link click handler and directly addresses the duplicate-tab behavior described in issue #9386. No unrelated code changes are present.
Full details: Description check

Explanation

The description explains the issue, root cause, fix, test limitations, validation steps, and linked issue. It omits the template headings for Type of Change and Screenshots, but the required technical information is present.

Full details: Linked Issues check

Explanation

The change meets issue #9386 by calling event.preventDefault() before window.open() for left-click link handling. This prevents native navigation from opening a second tab and leaves non-left-click behavior unchanged.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Left-clicking a link in a read-only comment/description opens two tabs

2 participants