0
0
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:
Trevor Buckner
2025-11-15 03:56:30 +00:00
parent 5625121b82
commit 72e954e7a4

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;
};
}, []);