jgraph / drawio

draw.io is a JavaScript, client-side editor for general diagramming.
https://www.drawio.com
Apache License 2.0
40.39k stars 7.55k forks source link

Link opens in new tab/window when it should open in the same window (Grafana FlowCharting Plugin) #2371

Closed psheehymn closed 2 years ago

psheehymn commented 2 years ago

Preflight Checklist

Describe the bug I was directed to this project from the grafana-flowcharting project (https://github.com/algenty/grafana-flowcharting) which is based on drawio.

Using the FlowCharting visualization plugin in Grafana, I created a diagram using the draw.io editor. I added a link to one of my objects and left the “Open in New Window” checkbox blank. Despite that, clicking the object opens the link page in a new tab.

As an experiment, I checked the “Open in New Window” checkbox and I saw that doing so added the linkTarget keyword to the UserObject tag with a value of “_blank”. In searching the internet, I saw a number of references (including in the Grafana API documentation) saying that the linkTarget keyword supports “_blank” and “_self”, with the latter value expected to cause the target to open in the current tab.

I manually edited the XML directly in the Grafana Edit Panel, changing the “_blank” to “_self” and saved the dashboard. However, after applying the change, it still did not deliver the desired outcome and the target still opens in a new tab.

To Reproduce Steps to reproduce the behavior:

  1. Create a panel on a page in Grafna.
  2. Specify the FlowCharting visualization.
  3. Click the Edit Draw button to open the draw.io editor.
  4. Add a shape to the drawing.
  5. Right click the object and select "Edit Link..." from the context menu.
  6. Specify a URL and leave the "Open in a New Window" checkbox unselected.
  7. Save the drawing.
  8. Click the "Extract/Decode" and "Prettify" options.
  9. Examine the XML and verify that the UserObject tag for the object does NOT contain the linkTarget keyword.
  10. Click the Save option for the panel.
  11. Click the Apply option for the panel.
  12. Refresh the dashboard page to ensure the latest version of the panel.
  13. Click the shape to go to the link URL. It will open a new window.

Expected behavior Without linkTarget specified or with it set to "_self" the URL should open within the same tab.

Screenshots If applicable, add screenshots to help explain your problem. Annotation 2021-11-01 115704-1 Annotation 2021-11-01 115704-2

draw.io version (In the Help->About menu of the draw.io editor):

Desktop (please complete the following information):

Additional context Here is the entire XML for the drawing:

psheehymn commented 2 years ago

DrawingXML.txt The XML of the drawing in the original post appears to have been truncated from the Additional Context section, so here is a text file with the content.

psheehymn commented 2 years ago

Can I get a response to this issue? Can someone confirm that not checking the "Open in New Window" option within the link dialog does cause the link to open within the same tab/window in a standalone draw.io diagram?

davidjgraph commented 2 years ago

We'd need a reproduction case that doesn't involve a third-party integration, i.e. happens on this project alone.

psheehymn commented 2 years ago

I do not have a way to do a native draw.io implementation, unless someone can direct me to a test site where I can make a drawing and then have it somehow available as or thru a web page (outside of Grafana, I am not even sure of the mechanism for doing such). In our very restricted corporate environment, I can only use draw,io thru Grafana.

That said, as stated in my last comment from Nov 22, 2021, if someone can confirm that not checking the "Open in New Window" option within the link dialog does cause the link to open within the same tab/window in a standalone draw.io diagram, that would be sufficient as far as I am concerned. If it works correctly in the native implementation, I can take that back to the author of the Grafana plugin as evidence the issue is with the Grafana plugin and how it is interacting with draw.io and that it is not a draw.io bug. I simply have no way currently to perform that proof on my own.

mariaiff commented 2 years ago

Hi, I'm trying to create a link through Draw.io without enabling the option to open a new tab and it's opening a new tab. I also did a test creating a direct link by the flowcharting rule and it also opens a new tab. Is there any way to open the page in the same tab? Grafana version 8.5.5

jeffreycrosby commented 2 years ago

I myself have been searching high and low for a solution to open links from shapes within draw.io (which has become diagrams.net now), using the flowcharting plugin for Grafana. Checked or unchecked, target specified or not - it always opens in a new tab. However if you create a text link in diagrams.net, and then double-click that text - you can create a link and it will open in the same tab (Windows 10, Chrome...). I haven't found anything useful at all to explain this behavior, nor any solution (for shapes). Of course very happy to learn more if anyone else has experience/knowledge/opinions, whatever!