0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

Handle unsaved warning with onbeforeunload

This commit is contained in:
MiniX16
2025-11-13 12:16:37 +01:00
parent 590688f123
commit b66625e59d

View File

@@ -78,13 +78,15 @@ const HomePage =(props)=>{
}
};
window.addEventListener('beforeunload', handleBeforeUnload);
const previousBeforeUnload = window.onbeforeunload;
window.onbeforeunload = handleBeforeUnload;
document.addEventListener('keydown', handleControlKeys);
return ()=>{
document.removeEventListener('keydown', handleControlKeys);
window.removeEventListener('beforeunload', handleBeforeUnload);
window.onbeforeunload = previousBeforeUnload;
};
}, []);