Skip to content

Commit d0e433e

Browse files
author
Maja Grubic
committed
Only use onAppLeave if coming from dashboard/canvas
1 parent 2e6ff13 commit d0e433e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/plugins/visualize/public/application/components/visualize_top_nav.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ const TopNav = ({
139139

140140
useEffect(() => {
141141
onAppLeave((actions) => {
142-
// Confirm when the user has made any changes to an existing doc
142+
// Confirm when the user has made any changes to an existing visualizations
143143
// or when the user has configured something without saving
144-
if (hasUnappliedChanges || hasUnsavedChanges) {
144+
if (
145+
((originatingApp && originatingApp === 'dashboards') || originatingApp === 'canvas') &&
146+
(hasUnappliedChanges || hasUnsavedChanges)
147+
) {
145148
return actions.confirm(
146149
i18n.translate('visualize.confirmModal.confirmTextDescription', {
147150
defaultMessage: 'Leave Visualize editor with unsaved changes?',
@@ -154,7 +157,13 @@ const TopNav = ({
154157
return actions.default();
155158
}
156159
});
157-
}, [onAppLeave, hasUnappliedChanges, hasUnsavedChanges, visualizeCapabilities.save]);
160+
}, [
161+
onAppLeave,
162+
hasUnappliedChanges,
163+
hasUnsavedChanges,
164+
visualizeCapabilities.save,
165+
originatingApp,
166+
]);
158167

159168
useEffect(() => {
160169
if (!vis.data.indexPattern) {

0 commit comments

Comments
 (0)