mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 16:22:44 +00:00
Modify slightly to follow the existing structure in editPage.jsx for easier merging of these pages later
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user