From 72e954e7a429ff50dde772acbf059a9c7ce27d9b Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 15 Nov 2025 03:56:30 +0000 Subject: [PATCH] Modify slightly to follow the existing structure in editPage.jsx for easier merging of these pages later --- client/homebrew/pages/homePage/homePage.jsx | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/client/homebrew/pages/homePage/homePage.jsx b/client/homebrew/pages/homePage/homePage.jsx index 9a779a070..463df333b 100644 --- a/client/homebrew/pages/homePage/homePage.jsx +++ b/client/homebrew/pages/homePage/homePage.jsx @@ -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; }; }, []);