Skip to content

Commit

Permalink
Also confirm unsaved changes on route update (location change)
Browse files Browse the repository at this point in the history
  • Loading branch information
hvangeffen authored and wkramer committed Apr 30, 2024
1 parent adf4ea0 commit 944a7c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/timeseries/TimeSeriesComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { configManager } from '../../services/application-config'
import { useSystemTimeStore } from '@/stores/systemTime'
import type { TimeSeriesEvent } from '@deltares/fews-pi-requests'
import { useDisplay } from 'vuetify'
import { onBeforeRouteLeave } from 'vue-router'
import { onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router'
interface Props {
config?: DisplayConfig
Expand Down Expand Up @@ -183,7 +183,9 @@ onUnmounted(() => {
window.onbeforeunload = null
})
onBeforeRouteLeave(() => {
onBeforeRouteLeave(confirmUnsavedChanges)
onBeforeRouteUpdate(confirmUnsavedChanges)
function confirmUnsavedChanges() {
if (isEditing.value) {
// For multiple simultaneous leaves set to false since confirm dialog is async
isEditing.value = false
Expand All @@ -197,7 +199,7 @@ onBeforeRouteLeave(() => {
return false
}
}
})
}
</script>

<style scoped>
Expand Down

0 comments on commit 944a7c3

Please sign in to comment.