0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-09 09:48:40 +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
+4 -2
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;
};
}, []);