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} />