Skip to content

Commit

Permalink
fix: Prevent navigating away when step queue is not empty
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Aug 13, 2024
1 parent f616406 commit 30663b0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ export default {
subscribe('text:image-node:delete', this.onDeleteImageNode)
this.emit('update:loaded', true)
subscribe('text:translate-modal:show', this.showTranslateModal)
window.addEventListener('beforeunload', (e) => {
if (this.$queue.length > 0) {
e.preventDefault()
e.returnValue = t('text', 'Some changes have not been synced. You might loose your edits when leaving the page.')
}
})
},
created() {
this.$ydoc = new Doc()
Expand Down

0 comments on commit 30663b0

Please sign in to comment.