From 074f5b35b170a1912eb722a16a1c34ff89b11f43 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 5 Jan 2017 15:27:57 -0500 Subject: [PATCH] fix #243 --- client/components/Nav.jsx | 6 +++++- client/modules/IDE/actions/project.js | 4 +++- client/modules/IDE/pages/IDEView.jsx | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index 53071f0f..65a07793 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -8,7 +8,11 @@ function Nav(props) {
  • { + if (props.warnIfUnsavedChanges()) { + props.newProject(); + } + }} > New diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index 837639d4..d5d0b179 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -143,7 +143,9 @@ export function resetProject() { } export function newProject() { - browserHistory.push('/'); + setTimeout(() => { + browserHistory.push('/'); + }, 0); return resetProject(); } diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index c36e61d9..5fcf4c8f 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -191,6 +191,7 @@ class IDEView extends React.Component { return false; } this.props.setUnsavedChanges(false); + return true; } } @@ -209,6 +210,7 @@ class IDEView extends React.Component { stopSketch={this.props.stopSketch} showShareModal={this.props.showShareModal} openForceAuthentication={this.props.openForceAuthentication} + warnIfUnsavedChanges={this.warnIfUnsavedChanges} />