Skip to content

Conversation

praneeth622
Copy link
Contributor

Fixes #6865 where openOnClick: false was being ignored. The issue was that when openOnClick was false, no click handler plugin was added, allowing browser's default anchor behavior to take over.

Now the click handler plugin is always added and controls behavior through preventDefault() and conditional window.open() based on the openOnClick setting.

Changes Overview

Modified the Link extension to always register the click handler plugin regardless of the openOnClick setting. The plugin now internally handles the openOnClick logic by always preventing default browser behavior and conditionally opening links based on the configuration.

Implementation Approach

  • Root cause: When openOnClick: false, no click handler plugin was registered, so browser default anchor behavior prevailed
  • Solution: Always add the click handler plugin but control link opening behavior internally
  • Modified files: clickHandler.ts to accept and handle openOnClick parameter, link.ts to always pass the setting to the plugin
  • Key logic: event.preventDefault() always called, window.open() called conditionally based on openOnClick value

Testing Done

  • Manual testing in React and Vue demos confirms links no longer open when openOnClick: false
  • Verified all three openOnClick states work correctly: true, false, 'whenNotEditable'
  • Build passes successfully with no TypeScript or linting errors
  • Created Cypress test suite covering all openOnClick scenarios

Verification Steps

  1. Checkout the branch and run npm run build
  2. Start dev server with npm run dev
  3. Navigate to React Link demo at http://localhost:3000/src/Marks/Link/React/
  4. Observe demo uses openOnClick: false configuration
  5. Click on links in editor content - they should NOT open in new tabs
  6. Verify you can edit link text instead of navigating away

Additional Notes

  • Maintains full backward compatibility with existing configurations
  • No performance impact as click handler was already conditionally added
  • Properly handles deprecated 'whenNotEditable' option
  • Solution prevents default behavior for all link clicks, then conditionally opens based on setting

Checklist

  • I have created a changeset for this PR if necessary.
  • My changes do not break the library.
  • I have added tests where applicable.
  • I have followed the project guidelines.
  • I have fixed any lint issues.

Related Issues

Fixes #6865

Fixes ueberdosis#6865 where openOnClick: false was being ignored. The issue was that when openOnClick was false, no click handler plugin was added, allowing browser's default anchor behavior to take over.

Now the click handler plugin is always added and controls behavior through preventDefault() and conditional window.open() based on the openOnClick setting.
Copy link

changeset-bot bot commented Sep 5, 2025

⚠️ No Changeset found

Latest commit: ad09fdb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Sep 5, 2025

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit ad09fdb
🔍 Latest deploy log https://app.netlify.com/projects/tiptap-embed/deploys/68cf0c83aa909e000834ee42
😎 Deploy Preview https://deploy-preview-6916--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

pkg-pr-new bot commented Sep 5, 2025

Open in StackBlitz

@tiptap/extension-character-count

npm i https://pkg.pr.new/@tiptap/extension-character-count@6916

@tiptap/extension-dropcursor

npm i https://pkg.pr.new/@tiptap/extension-dropcursor@6916

@tiptap/extension-focus

npm i https://pkg.pr.new/@tiptap/extension-focus@6916

@tiptap/extension-gapcursor

npm i https://pkg.pr.new/@tiptap/extension-gapcursor@6916

@tiptap/extension-history

npm i https://pkg.pr.new/@tiptap/extension-history@6916

@tiptap/extension-list-item

npm i https://pkg.pr.new/@tiptap/extension-list-item@6916

@tiptap/extension-table-cell

npm i https://pkg.pr.new/@tiptap/extension-table-cell@6916

@tiptap/extension-placeholder

npm i https://pkg.pr.new/@tiptap/extension-placeholder@6916

@tiptap/extension-list-keymap

npm i https://pkg.pr.new/@tiptap/extension-list-keymap@6916

@tiptap/extension-table-row

npm i https://pkg.pr.new/@tiptap/extension-table-row@6916

@tiptap/extension-table-header

npm i https://pkg.pr.new/@tiptap/extension-table-header@6916

@tiptap/extension-task-item

npm i https://pkg.pr.new/@tiptap/extension-task-item@6916

@tiptap/extension-task-list

npm i https://pkg.pr.new/@tiptap/extension-task-list@6916

@tiptap/core

npm i https://pkg.pr.new/@tiptap/core@6916

@tiptap/extension-blockquote

npm i https://pkg.pr.new/@tiptap/extension-blockquote@6916

@tiptap/extension-bold

npm i https://pkg.pr.new/@tiptap/extension-bold@6916

@tiptap/extension-bubble-menu

npm i https://pkg.pr.new/@tiptap/extension-bubble-menu@6916

@tiptap/extension-bullet-list

npm i https://pkg.pr.new/@tiptap/extension-bullet-list@6916

@tiptap/extension-code-block

npm i https://pkg.pr.new/@tiptap/extension-code-block@6916

@tiptap/extension-code

npm i https://pkg.pr.new/@tiptap/extension-code@6916

@tiptap/extension-code-block-lowlight

npm i https://pkg.pr.new/@tiptap/extension-code-block-lowlight@6916

@tiptap/extension-collaboration-caret

npm i https://pkg.pr.new/@tiptap/extension-collaboration-caret@6916

@tiptap/extension-collaboration

npm i https://pkg.pr.new/@tiptap/extension-collaboration@6916

@tiptap/extension-details

npm i https://pkg.pr.new/@tiptap/extension-details@6916

@tiptap/extension-document

npm i https://pkg.pr.new/@tiptap/extension-document@6916

@tiptap/extension-color

npm i https://pkg.pr.new/@tiptap/extension-color@6916

@tiptap/extension-drag-handle

npm i https://pkg.pr.new/@tiptap/extension-drag-handle@6916

@tiptap/extension-drag-handle-react

npm i https://pkg.pr.new/@tiptap/extension-drag-handle-react@6916

@tiptap/extension-drag-handle-vue-2

npm i https://pkg.pr.new/@tiptap/extension-drag-handle-vue-2@6916

@tiptap/extension-drag-handle-vue-3

npm i https://pkg.pr.new/@tiptap/extension-drag-handle-vue-3@6916

@tiptap/extension-emoji

npm i https://pkg.pr.new/@tiptap/extension-emoji@6916

@tiptap/extension-file-handler

npm i https://pkg.pr.new/@tiptap/extension-file-handler@6916

@tiptap/extension-floating-menu

npm i https://pkg.pr.new/@tiptap/extension-floating-menu@6916

@tiptap/extension-font-family

npm i https://pkg.pr.new/@tiptap/extension-font-family@6916

@tiptap/extension-hard-break

npm i https://pkg.pr.new/@tiptap/extension-hard-break@6916

@tiptap/extension-highlight

npm i https://pkg.pr.new/@tiptap/extension-highlight@6916

@tiptap/extension-heading

npm i https://pkg.pr.new/@tiptap/extension-heading@6916

@tiptap/extension-horizontal-rule

npm i https://pkg.pr.new/@tiptap/extension-horizontal-rule@6916

@tiptap/extension-image

npm i https://pkg.pr.new/@tiptap/extension-image@6916

@tiptap/extension-invisible-characters

npm i https://pkg.pr.new/@tiptap/extension-invisible-characters@6916

@tiptap/extension-link

npm i https://pkg.pr.new/@tiptap/extension-link@6916

@tiptap/extension-italic

npm i https://pkg.pr.new/@tiptap/extension-italic@6916

@tiptap/extension-list

npm i https://pkg.pr.new/@tiptap/extension-list@6916

@tiptap/extension-mathematics

npm i https://pkg.pr.new/@tiptap/extension-mathematics@6916

@tiptap/extension-node-range

npm i https://pkg.pr.new/@tiptap/extension-node-range@6916

@tiptap/extension-mention

npm i https://pkg.pr.new/@tiptap/extension-mention@6916

@tiptap/extension-ordered-list

npm i https://pkg.pr.new/@tiptap/extension-ordered-list@6916

@tiptap/extension-paragraph

npm i https://pkg.pr.new/@tiptap/extension-paragraph@6916

@tiptap/extension-strike

npm i https://pkg.pr.new/@tiptap/extension-strike@6916

@tiptap/extension-subscript

npm i https://pkg.pr.new/@tiptap/extension-subscript@6916

@tiptap/extension-superscript

npm i https://pkg.pr.new/@tiptap/extension-superscript@6916

@tiptap/extension-table

npm i https://pkg.pr.new/@tiptap/extension-table@6916

@tiptap/extension-text

npm i https://pkg.pr.new/@tiptap/extension-text@6916

@tiptap/extension-table-of-contents

npm i https://pkg.pr.new/@tiptap/extension-table-of-contents@6916

@tiptap/extension-text-align

npm i https://pkg.pr.new/@tiptap/extension-text-align@6916

@tiptap/extension-typography

npm i https://pkg.pr.new/@tiptap/extension-typography@6916

@tiptap/extension-text-style

npm i https://pkg.pr.new/@tiptap/extension-text-style@6916

@tiptap/extension-underline

npm i https://pkg.pr.new/@tiptap/extension-underline@6916

@tiptap/extension-unique-id

npm i https://pkg.pr.new/@tiptap/extension-unique-id@6916

@tiptap/extension-youtube

npm i https://pkg.pr.new/@tiptap/extension-youtube@6916

@tiptap/html

npm i https://pkg.pr.new/@tiptap/html@6916

@tiptap/extensions

npm i https://pkg.pr.new/@tiptap/extensions@6916

@tiptap/pm

npm i https://pkg.pr.new/@tiptap/pm@6916

@tiptap/react

npm i https://pkg.pr.new/@tiptap/react@6916

@tiptap/starter-kit

npm i https://pkg.pr.new/@tiptap/starter-kit@6916

@tiptap/suggestion

npm i https://pkg.pr.new/@tiptap/suggestion@6916

@tiptap/static-renderer

npm i https://pkg.pr.new/@tiptap/static-renderer@6916

@tiptap/vue-2

npm i https://pkg.pr.new/@tiptap/vue-2@6916

@tiptap/vue-3

npm i https://pkg.pr.new/@tiptap/vue-3@6916

commit: ad09fdb

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.

[Link] openOnClick option is ignored
1 participant