diff --git a/frontend/composables/use-navigation-warning.ts b/frontend/composables/use-navigation-warning.ts index f07d842ae..2dff77d39 100644 --- a/frontend/composables/use-navigation-warning.ts +++ b/frontend/composables/use-navigation-warning.ts @@ -1,7 +1,22 @@ -export const activateNavigationWarning = () => { +export function useNavigationWarning() { + return { activateNavigationWarning, deactivateNavigationWarning }; +} + +/** + * Displays a warning before the user navigates to another page + * e.g., by clicking a link (which isn't internal and rendered without page load), + * reloading the page, + * or closing the tab. + */ +const activateNavigationWarning = () => { + console.log("ACTIVATE"); window.onbeforeunload = () => true; } -export const deactivateNavigationWarning = () => { +/** + * Disables the warning when navigating to a page + */ +const deactivateNavigationWarning = () => { + console.log("deACTIVATE"); window.onbeforeunload = null; }