Skip to content

fix(editor): left-click on a link in read-only content opens two tabs - #10179

Merged
sriramveeraghanta merged 1 commit into
makeplane:previewfrom
Krish6115:fix/readonly-link-opens-two-tabs
Nov 23, 2026
Merged

sriramveeraghanta merged 1 commit into
makeplane:previewfrom
Krish6115:fix/readonly-link-opens-two-tabs

Conversation

@Krish6115

@Krish6115 Krish6115 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Left-clicking a link in a read-only (non-editable) comment or description opened it in two tabs. The handleClick plugin in clickHandler.ts called window.open(...) without event.preventDefault(), so the browser also followed the native <a target="_blank">. In editable mode ProseMirror already suppresses the native click, which is why only read-only views were affected.

The fix calls event.preventDefault() before window.open.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Scenarios

Code-level change (one line); traced the handler path for editable and non-editable views. Not manually exercised in a browser.

References

Closes #9386

Summary by CodeRabbit

  • Bug Fixes
    • Clicked links now open in a new browsing context without triggering the browser’s default navigation in the current one. This keeps the current page in place while the destination opens, preventing the editor view from changing unexpectedly when a link is clicked.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 14:08
@CLAassistant

CLAassistant commented Nov 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Krish6115
Krish6115 force-pushed the fix/readonly-link-opens-two-tabs branch from 4f339da to 5ad9692 Compare November 3, 2026 14:09
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The custom link click handler now calls event.preventDefault() before window.open() when it finds a valid link. This prevents the anchor’s default navigation from also opening the link.

Changes: Custom link click handling

Layer / File(s) Summary
Suppress native link navigation
packages/editor/src/extensions/custom-link/helpers/clickHandler.ts
The handler calls preventDefault() before window.open() for a valid link.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Suggested reviewers: sriramveeraghanta

Merge Risk: Minimal · up to 3acd8

This change stops links in read-only comments and descriptions from opening in two tabs on left-click. The change is small and localized, and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the bug and the fix area: a left-click on a link in read-only content opens two tabs. It is specific to the changeset, which adds event.preventDefault() in clickHandler.ts before windo…
Description check Passed The description states the problem, the cause (window.open called without event.preventDefault(), so the browser also followed the native target=_blank anchor), why editable mode is unaffected, and th…
Linked Issues check Passed Issue #9386 requires one tab per left-click on a link in read-only comment or description content. The whole-PR diff (merge base to head) adds event.preventDefault() in `packages/editor/src/extensio…
Out of Scope Changes check Passed The whole-PR diff changes one file, packages/editor/src/extensions/custom-link/helpers/clickHandler.ts, with +3/-0 lines. The added lines are a comment and one event.preventDefault() call, and bot…
Full details: Title check

Explanation

The title names the bug and the fix area: a left-click on a link in read-only content opens two tabs. It is specific to the changeset, which adds event.preventDefault() in clickHandler.ts before window.open to stop the duplicate native navigation. It uses the conventional fix(editor) prefix and is under 70 characters.

Full details: Description check

Explanation

The description states the problem, the cause (window.open called without event.preventDefault(), so the browser also followed the native target=_blank anchor), why editable mode is unaffected, and the one-line fix. It marks the Bug fix type and links the issue (Closes #9386). The Screenshots and References sections are present in the template but not filled in. Screenshots are optional for this change, and the issue link covers the reference. The Test Scenarios section says the change was traced in code but not exercised in a browser, which is a gap in verification.

Full details: Linked Issues check

Explanation

Issue #9386 requires one tab per left-click on a link in read-only comment or description content. The whole-PR diff (merge base to head) adds event.preventDefault() in packages/editor/src/extensions/custom-link/helpers/clickHandler.ts, before the window.open(...) call. This matches the suggested fix in the issue. The issue cites packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts. The file exists at packages/editor/src/extensions/custom-link/... at the reviewed head. The path difference does not change the result. The PR adds a code comment that explains the double-open cause. The issue does not request an automated test, and the PR adds none. The one-tab result depends on ProseMirror passing the click event that the native anchor activation uses. That runtime behavior is outside the repository and was not exercised in a browser. The incremental diff against the previous reviewed head could not be read. The whole-PR diff was used instead, so this result rests on the current head.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff changes one file, packages/editor/src/extensions/custom-link/helpers/clickHandler.ts, with +3/-0 lines. The added lines are a comment and one event.preventDefault() call, and both serve #9386. The window.open line with its _self/_blank target handling and noopener,noreferrer features appears as unchanged context, so it existed at the merge base and is not introduced by this PR. No unrelated behavior is introduced.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 025911ae-fa9c-4f36-9db8-d9a9dfbaa6af
Commits

Reviewing files that changed from the base of the PR and between 5ad9692 and 3acd8eb.

Files selected for processing: 1

  • packages/editor/src/extensions/custom-link/helpers/clickHandler.ts

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

@Krish6115

Copy link
Copy Markdown
Contributor Author

Hi @anmolsinghbhatia, whenever you have some free time, could you please review this PR? It's a small change. Happy to make any adjustments needed. Thanks!

@Krish6115

Copy link
Copy Markdown
Contributor Author

Hi @prateekshourya29, thanks for merging my earlier PRs. Whenever you get a chance, could you take a look at this one too? Happy to make any changes needed.

@sriramveeraghanta

Copy link
Copy Markdown
Member

@Krish6115 there is a merge conflict in this PR. Please look into it.

@Krish6115
Krish6115 force-pushed the fix/readonly-link-opens-two-tabs branch from 5ad9692 to 3acd8eb Compare November 23, 2026 08:09
@Krish6115

Copy link
Copy Markdown
Contributor Author

@Krish6115 there is a merge conflict in this PR. Please look into it.

Hi @sriramveeraghanta , I have resolved the merge conflict with preview (upstream had reworked clickhandler so I rebased and kept the new handler with only the event.preventDefault() fix on top)... The Pr is mergable now :)

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

5 participants