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

Bug/Clicking on a link only works directly on the node text #1163

Conversation

GDFaber
Copy link
Member

@GDFaber GDFaber commented Dec 26, 2019

📑 Summary

Improved flowchart renderer to set links on the entire node so you can click a link anywhere on the node (before this modification it was only possible by clicking the node label).

Resolves #891

📏 Design Decisions

Used DOM manipulation inside the SVG node to wrap the shape as well as the label in an anchor object. Did not include additional tests to renderer, interaction or cypress integration because they already exist.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added unit/e2e tests (if appropriate)
  • 🔖 targeted develop branch

@klemmchr klemmchr requested a review from knsv December 26, 2019 15:24
@klemmchr klemmchr added Graph: Flow Type: Bug / Error Something isn't working or is incorrect labels Dec 26, 2019
Copy link
Collaborator

@knsv knsv left a comment

Choose a reason for hiding this comment

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

Looks good!

@knsv knsv merged commit 2db8075 into mermaid-js:develop Dec 31, 2019
@GDFaber GDFaber deleted the bug/891_make_link_clickable_on_the_entire_node branch January 1, 2020 01:32
@flying-sheep
Copy link
Contributor

flying-sheep commented Feb 21, 2020

Great stuff! I already fixed that in some 0.x release, but it broke again. Kudos for fixing it again!

@dunning-kruger @jgreywolf since I can’t comment there because it’s locked – This works because of the way SVG differs from HTML:

  1. pointer events (hover, click, …) register on the actual object’s shape, not some box around it.
  2. <a> and <g> nodes also don’t create a box, but instead they affect all the shapes inside: <g fill=#f00><rect .../><circle .../></g> makes everything inside red, and <a href="..."><rect .../><circle .../></a> makes every shape inside link to the URL when clicked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graph: Flow Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking on a link only works directly on the node text
4 participants