From 67700ad928619f8cd8b833b22bd7b937bc76ad57 Mon Sep 17 00:00:00 2001 From: Linda Paiste Date: Thu, 9 Nov 2023 21:46:06 -0600 Subject: [PATCH 1/2] Remove `setTimeout` --- client/modules/IDE/actions/project.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index 3c2aca691..2787f303e 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -270,9 +270,7 @@ export function resetProject() { } export function newProject() { - setTimeout(() => { - browserHistory.push('/'); - }, 0); + browserHistory.push('/'); return resetProject(); } From f9b12686297a8ea86a322a680b3c891d05bccaf1 Mon Sep 17 00:00:00 2001 From: Linda Paiste Date: Fri, 10 Nov 2023 18:48:48 -0600 Subject: [PATCH 2/2] Prevent double alert. --- client/modules/IDE/actions/project.js | 2 +- client/modules/IDE/pages/IDEView.jsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index 2787f303e..00006f943 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -270,7 +270,7 @@ export function resetProject() { } export function newProject() { - browserHistory.push('/'); + browserHistory.push('/', { confirmed: true }); return resetProject(); } diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 718613c5e..02056ba0a 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -56,7 +56,8 @@ function WarnIfUnsavedChanges() { isAuth(nextLocation.pathname) || isAuth(currentLocation.pathname) || isOverlay(nextLocation.pathname) || - isOverlay(currentLocation.pathname) + isOverlay(currentLocation.pathname) || + nextLocation.state?.confirmed ) { return true; // allow navigation }