From ff88e173f5f20965ba8a5730dc91b7895a486623 Mon Sep 17 00:00:00 2001 From: Nar Saynorath Date: Tue, 27 May 2025 16:17:26 -0400 Subject: [PATCH 1/2] fix(dashboards): Only prompt for changes if in editing mode --- static/app/views/dashboards/detail.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/app/views/dashboards/detail.tsx b/static/app/views/dashboards/detail.tsx index 6be21c23a1be7c..a67f7eb154e578 100644 --- a/static/app/views/dashboards/detail.tsx +++ b/static/app/views/dashboards/detail.tsx @@ -1133,7 +1133,9 @@ class DashboardDetail extends Component { (checkDashboardRoute(locationChange.currentLocation.pathname) && checkDashboardRoute(locationChange.nextLocation.pathname)); const hasUnsavedChanges = - defined(modifiedDashboard) && !isEqual(modifiedDashboard, dashboard); + defined(modifiedDashboard) && + !isEqual(modifiedDashboard, dashboard) && + this.isEditingDashboard; return ( locationChange.currentLocation.pathname !== locationChange.nextLocation.pathname && From 8af4d4bfa0fa91fe9c91f654d68caf84f3296675 Mon Sep 17 00:00:00 2001 From: Nar Saynorath Date: Wed, 28 May 2025 10:07:04 -0400 Subject: [PATCH 2/2] Add editing condition to window unload event --- static/app/views/dashboards/detail.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/app/views/dashboards/detail.tsx b/static/app/views/dashboards/detail.tsx index a67f7eb154e578..8b6b076e3218a6 100644 --- a/static/app/views/dashboards/detail.tsx +++ b/static/app/views/dashboards/detail.tsx @@ -433,7 +433,11 @@ class DashboardDetail extends Component { handleBeforeUnload = (event: BeforeUnloadEvent) => { const {dashboard} = this.props; const {modifiedDashboard} = this.state; - if (defined(modifiedDashboard) && !isEqual(modifiedDashboard, dashboard)) { + if ( + defined(modifiedDashboard) && + !isEqual(modifiedDashboard, dashboard) && + this.isEditingDashboard + ) { event.preventDefault(); event.returnValue = ''; }