Mermaid: toggle window on click

I am currently developing a tool to generate a mermaid graph using mermaid.js

Such graph is generated using Python and looks like:

<script type="module">import mermaid  from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';</script>
<script>
  mermaid.initialize({
    securityLevel: 'loose',
  });
</script>
<script>my_function(node_name){alert("my_function is called with ${node_name}")}</script>
<div classname="mermaid">
flowchart TD

subgraph tqt
    test_node[test_node]-->|this is an example message|test_node2[test_node2]
end

click test_node my_function("test_node")

</div>

I notice that the “click” function can trigger a callback.

Now, I am looking for a way to toggle a window to show more details for a specific node (using my_function callback).

If I click one a node, a specific sub window should appear. If I click again it should disappear (with CSS this is doable I think).

If I click one a node, a specific sub window should appear, but if I click on another node when a window is open, it should toggle off the current sub window and open the new one.

I am not sure how to do it, especially because lot’s of comment says that the mermaid.js click feature is pretty limited. I am wondering if this is easy to do(should I save the current state in a JavaScript variable??)

Thank you for your help, mockup is coming.