@@ -53,12 +53,11 @@ const ProjectSaverHOC = function (WrappedComponent) {
5353 ] ) ;
5454 }
5555 componentWillMount ( ) {
56- if ( typeof window === 'object' ) {
56+ if ( ! this . props . noBeforeUnloadHandler && typeof window === 'object' ) {
5757 // Note: it might be better to use a listener instead of assigning onbeforeunload;
5858 // but then it'd be hard to turn this listening off in our tests
5959 window . onbeforeunload = e => this . leavePageConfirm ( e ) ;
6060 }
61-
6261 // Allow the GUI consumer to pass in a function to receive a trigger
6362 // for triggering thumbnail or whole project saves.
6463 // These functions are called with null on unmount to prevent stale references.
@@ -343,6 +342,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
343342 onUpdatedProject,
344343 onUpdateProjectData,
345344 onUpdateProjectThumbnail,
345+ noBeforeUnloadHandler,
346346 reduxProjectId,
347347 reduxProjectTitle,
348348 setAutoSaveTimeoutId : setAutoSaveTimeoutIdProp ,
@@ -395,6 +395,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
395395 onUpdateProjectData : PropTypes . func ,
396396 onUpdateProjectThumbnail : PropTypes . func ,
397397 onUpdatedProject : PropTypes . func ,
398+ noBeforeUnloadHandler : PropTypes . bool . required ,
398399 projectChanged : PropTypes . bool ,
399400 reduxProjectId : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
400401 reduxProjectTitle : PropTypes . string ,
@@ -406,7 +407,8 @@ const ProjectSaverHOC = function (WrappedComponent) {
406407 autoSaveIntervalSecs : 600 , // 10 minutes = 600 seconds
407408 onRemixing : ( ) => { } ,
408409 onSetProjectThumbnailer : ( ) => { } ,
409- onSetProjectSaver : ( ) => { }
410+ onSetProjectSaver : ( ) => { } ,
411+ noBeforeUnloadHandler : false
410412 } ;
411413 const mapStateToProps = ( state , ownProps ) => {
412414 const loadingState = state . scratchGui . projectState . loadingState ;
0 commit comments