mirror of
https://github.com/directus/directus.git
synced 2026-02-17 17:02:11 -05:00
Merge pull request #757 from nickrum/leave-dialog-fix
Call navigation guard in item route component
This commit is contained in:
@@ -324,9 +324,7 @@ export default defineComponent({
|
||||
useShortcut('meta+shift+s', saveAndAddNew, form);
|
||||
|
||||
const navigationGuard: NavigationGuard = (to, from, next) => {
|
||||
const hasEdits = Object.keys(edits.value).length > 0;
|
||||
|
||||
if (hasEdits) {
|
||||
if (hasEdits.value) {
|
||||
confirmLeave.value = true;
|
||||
leaveTo.value = to.fullPath;
|
||||
return next(false);
|
||||
@@ -470,6 +468,12 @@ export default defineComponent({
|
||||
return { deleteAllowed, saveAllowed, archiveAllowed, updateAllowed };
|
||||
}
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
return (this as any).navigationGuard(to, from, next);
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
return (this as any).navigationGuard(to, from, next);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user