Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link click fix #4423

Merged
merged 4 commits into from
Nov 20, 2023
Merged

Link click fix #4423

merged 4 commits into from
Nov 20, 2023

Conversation

ioma8
Copy link

@ioma8 ioma8 commented Sep 7, 2023

Please describe your changes

I am improving on this pull request, which doesnt solve the issue (actually brings another one): #4346 (comment)

In the mentioned PR only when the exact A element is clicked, it opens the link. But there are cases, when you have mark Bold or some other on the link text as well. The B / STRONG element is rendered INSIDE the A element, thus the condition nodeName !== 'A' does check and it cancels opening the link. I fixed that.

How did you accomplish your changes

I iterate all clicked nodes nodeParents till I approach parent DIV node (inline node must be inside block node, so this is logical rule; Link is inline node). If none of those parent nodes are not A node, only then do I cancel the link opening. This handles all other marks (ie STRONG element inside A element etc) where it previously mistakengly canceled it.

Also I removed the condition that links are opened only when editor is in editable state. I think expected behaviour should be that links are always openable, even if the editor is not right in its edit state.

How have you tested your changes

I added test case into demos/src/Marks/Link/React/index.jsx (added B node inside first A node in the sample content). Previously the link didnt open, now it opens correctly.

How can we verify your changes

Test it, like I did.

Remarks

Checklist

  • [x ] The changes are not breaking the editor
  • [ x] Added tests where possible
  • [ x] Followed the guidelines
  • [ x] Fixed linting issues

Related issues

#4346 (comment)

@netlify
Copy link

netlify bot commented Sep 7, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit de8d4bf
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/655bbe53dbf09b0008c3cbc4
😎 Deploy Preview https://deploy-preview-4423--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 site configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants