grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
64.24k stars 12.02k forks source link

Grafana thinks I'm navigating away when I'm not - shows "Do you want to save your changes?" #74695

Open samjewell opened 1 year ago

samjewell commented 1 year ago

I find this SUPER irritating - it always interrupts me mid-flow, when I'm trying to make a lot of dashboard edits very quickly.

Watch this Loom video to build some empathy and feel my pain firsthand: https://www.loom.com/share/dde3ea455967459a9a196475f86baf43

What happened:

image

What I expected to happen

Reproduction steps

I've built a reproduction dashboard especially to reproduce the issue on this ticket. Just take these steps to see it in action:

  1. Load up https://play.grafana.org/d/forcesavebug/
  2. Click on a box within the treemap panel, and then click the link "View this dashboard for [metrics-slug]" to filter the dashboard
  3. Move the first stat panel to the top of the dashboard, above the treemap panel
  4. Move the second stat panel to the top of the dashboard, above the treemap panel
  5. Now try to edit one of the stat-panels. BOOM 💥 - Grafana thinks I'm navigating away from the dashboard, but I'm not. I'm not ready to commit my changes, and don't want to be forced to write a commit message yet. And my flow has been interrupted - I'm confused and now I've forgotten what I was doing, and why I wanted to edit the panel.
axelavargas commented 1 year ago

Hey @samjewell 👋🏾, thank you for bringing this issue to our attention. After investigating, I found that the issue originates from the datalink configured in the tree map panel.

Current URL redirected from data link: /d/forcesavebug/?var-org_slug=grafana&var-org_id=.....etc

Our current logic for displaying unsaved changes modals checks if we are redirecting to the same dashboard. This check is based on location.path(relevant code). In your dashboard example, the initially loaded dashboard URL is d/forcesavebug/walk-thru-and-repro-force-save-bug?var-org_slug=......etc (the path contain the dashboard name). When compared, these URLs are identified as different dashboards, which is incorrect.

Quick Workaround:

Change the data link to include the dashboard name: d/forcesavebug/walk-thru-and-repro-force-save-bug?${org_slug:queryparam}.

Proper Fix:

The correct solution is to enhance our logic for identifying if we are redirecting to the same dashboard. I will give it a try and see how hard is to fix this issue.

samjewell commented 1 year ago

I found that the issue originates from the datalink configured in the tree map panel.

Ah thanks so much, great to have found the root cause so quickly 😌

Change the data link to include the dashboard name:

Thanks also for sharing the workaround with me. I'd like to hold off doing this for now, however - I can see that including the dashboard name here will fix the issue, but only as long as the Dashboard itself doesn't get renamed. As soon as I rename the dashboard and save it, and then forget to update the data-links, won't the same problem occur again?

axelavargas commented 1 year ago

Hey @samjewell 👋🏾 ,

As soon as I rename the dashboard and save it, and then forget to update the data-links, won't the same problem occur again?

Yes, that's correct 😢

github-actions[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!