0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-23 18:43:02 +00:00

Compare commits

...

1 Commits

View File

@@ -70,23 +70,14 @@ const HomePage =(props)=>{
}
};
const handleBeforeUnload = (e)=>{
if(unsavedChangesRef.current) {
e.preventDefault();
e.returnValue = '';
return '';
}
};
const previousBeforeUnload = window.onbeforeunload;
window.onbeforeunload = handleBeforeUnload;
document.addEventListener('keydown', handleControlKeys);
window.onbeforeunload = ()=>{
if(unsavedChangesRef.current)
return 'You have unsaved changes!';
};
return ()=>{
document.removeEventListener('keydown', handleControlKeys);
window.onbeforeunload = previousBeforeUnload;
window.onbeforeunload = null;
};
}, []);