diff --git a/public/app/features/dashboard-scene/saving/DashboardPrompt.tsx b/public/app/features/dashboard-scene/saving/DashboardPrompt.tsx index 134e2cedbab..fb44176788f 100644 --- a/public/app/features/dashboard-scene/saving/DashboardPrompt.tsx +++ b/public/app/features/dashboard-scene/saving/DashboardPrompt.tsx @@ -16,7 +16,7 @@ import { DashboardMeta } from 'app/types/dashboard'; import { SaveLibraryVizPanelModal } from '../panel-edit/SaveLibraryVizPanelModal'; import { DashboardScene } from '../scene/DashboardScene'; -import { getLibraryPanelBehavior, isLibraryPanel } from '../utils/utils'; +import { getLibraryPanelBehavior, hasActualSaveChanges, isLibraryPanel } from '../utils/utils'; interface DashboardPromptProps { dashboard: DashboardScene; @@ -200,7 +200,7 @@ export function ignoreChanges(scene: DashboardScene | null) { return true; } - return !canSave || fromScript || fromFile; + return !canSave || fromScript || fromFile || (scene.state.isEditing && !hasActualSaveChanges(scene)); } export function isEmptyDashboard( diff --git a/public/app/features/dashboard-scene/scene/DashboardScene.tsx b/public/app/features/dashboard-scene/scene/DashboardScene.tsx index 0cabdf459a2..748d3e7986e 100644 --- a/public/app/features/dashboard-scene/scene/DashboardScene.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardScene.tsx @@ -72,6 +72,7 @@ import { getDefaultVizPanel, getLayoutManagerFor, getPanelIdForVizPanel, + hasActualSaveChanges, } from '../utils/utils'; import { SchemaV2EditorDrawer } from '../v2schema/SchemaV2EditorDrawer'; @@ -316,7 +317,7 @@ export class DashboardScene extends SceneObjectBase impleme return; } - if (!this.state.isDirty || skipConfirm || this.managedResourceCannotBeEdited()) { + if (!this.state.isDirty || skipConfirm || !hasActualSaveChanges(this) || this.managedResourceCannotBeEdited()) { this.exitEditModeConfirmed(restoreInitialState || this.state.isDirty); return; } diff --git a/public/app/features/dashboard-scene/utils/utils.ts b/public/app/features/dashboard-scene/utils/utils.ts index 12dba08eda4..419ce760b21 100644 --- a/public/app/features/dashboard-scene/utils/utils.ts +++ b/public/app/features/dashboard-scene/utils/utils.ts @@ -427,3 +427,11 @@ export function hasLibraryPanelsInV1Dashboard(dashboard: Dashboard | undefined): } export const dashboardLog = createLogger('Dashboard'); + +/** + * Checks if there are save changes but not counting time range, refresh rate and default variable value change + */ +export function hasActualSaveChanges(dashboard: DashboardScene) { + const changes = dashboard.getDashboardChanges(); + return !!changes.diffCount; +}