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

Docs workaround for failing callback() section #1323

Merged
merged 1 commit into from
Mar 30, 2020
Merged

Docs workaround for failing callback() section #1323

merged 1 commit into from
Mar 30, 2020

Conversation

kdipippo
Copy link
Contributor

📑 Summary

Under the Flowchart > Interaction section of the docs, the mermaid snippet for adding callback functions is not working as expected. Expected behavior is for a tooltip to appear on hover and for an alert to appear on click; neither of these behaviors are seen in the docs. In the original issue, I noted that the culprit may be due to the callback() function never being initialized.

Resolves #1294

🐛 Related Bug Investigation

There were a few attempts to get this to work inside the document itself that did not result in successes:

  1. In docs/index.html, I pasted the callback() function containing the alert. Running the docs locally, I was able to confirm that the function correctly initializes in console (result below). Clicking on the mermaid element still did not call that function.
typeof callback
> "function"
  1. I added securityLevel:'loose' to the mermaid init in docs/index.html; I later also set startOnLoad: true. Neither, coupled with the exposed callback() function, resulted in any changes.
  2. I updated the version of mermaid from 8.4.7 -> 8.4.8 in the docs, with no result.
  3. My initial hunch involved adding executeScript: true to the docs/index.html config: https://docsify.js.org/#/configuration?id=executescript However, this would only alleviate the issue of having to add all the callback functions from this doc page into the docs/index.html file.

The root cause is one of two issues:

  1. Docsify is improperly converting the markdown such that it breaks the callback functionality, based on how that process is set up in docs/index.html.
  2. An existing field being passed into mermaid.initialize({}); conflicts with the callback functionality. The first option seems more likely due to only 3 fields being passed here with no obvious culprits.

📏 Design Decisions

As a proposed workaround, I created a fiddle that uses mermaid 8.4.8 and runs the small callback demo, along with a note about these limitations. Screenshot of how this appears:

Screen Shot 2020-03-29 at 12 59 31 AM

📋 Tasks

Make sure you

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

@knsv
Copy link
Collaborator

knsv commented Mar 30, 2020

Thanks @Pepper-Wood ! This is much appreciated!

@knsv knsv merged commit d0492ec into mermaid-js:develop Mar 30, 2020
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.

Flowchart click interaction does not occur
2 participants