diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 83ec1bca..bc05ef2a 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -55,7 +55,7 @@ function warnIfUnsavedChanges(props) { // eslint-disable-line props.persistState(); window.onbeforeunload = null; } else if (props.ide.unsavedChanges) { - if (!window.confirm(this.props.t('WarningUnsavedChanges'))) { + if (!window.confirm(props.t('WarningUnsavedChanges'))) { return false; } props.setUnsavedChanges(false); @@ -90,9 +90,9 @@ class IDEView extends React.Component { this.isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1; document.addEventListener('keydown', this.handleGlobalKeydown, false); - this.props.router.setRouteLeaveHook(this.props.route, () => warnIfUnsavedChanges(this.props)); + this.props.router.setRouteLeaveHook(this.props.route, this.handleUnsavedChanges); - window.onbeforeunload = () => warnIfUnsavedChanges(); + window.onbeforeunload = this.handleUnsavedChanges; this.autosaveInterval = null; } @@ -205,9 +205,7 @@ class IDEView extends React.Component { } } - warnIfUnsavedChangesCaller(props) { - return warnIfUnsavedChanges(props); - } + handleUnsavedChanges = () => warnIfUnsavedChanges(this.props); render() { return ( @@ -217,7 +215,7 @@ class IDEView extends React.Component { {this.props.toast.isVisible && }