File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export default {
6161 data : () => ({
6262 categoryStore: useCategoryStore (),
6363 editingId: null ,
64+ routerGuardRemover: null ,
6465 }),
6566 computed: {
6667 ... mapState (useCategoryStore , [' classes_unsaved_changes' ]),
@@ -75,8 +76,7 @@ export default {
7576 // beforeEach hook
7677 window .addEventListener (' beforeunload' , this .beforeUnload );
7778
78- // TODO: How to remove this listener?
79- router .beforeEach ((to , from , next ) => {
79+ this .routerGuardRemover = router .beforeEach ((to , from , next ) => {
8080 try {
8181 if (this .classes_unsaved_changes ) {
8282 if (confirm (confirmationMessage )) {
@@ -95,6 +95,9 @@ export default {
9595 },
9696 beforeDestroy() {
9797 window .removeEventListener (' beforeunload' , this .beforeUnload );
98+ if (this .routerGuardRemover ) {
99+ this .routerGuardRemover ();
100+ }
98101 },
99102 methods: {
100103 addClass : function () {
You can’t perform that action at this time.
0 commit comments