From decf4a9c4dba3393081b7f1253b80487064d65e9 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 9 Jul 2020 12:50:46 -0400 Subject: [PATCH] [#1458] Fix merge bug, rename handler function - Fix bug in warnIfUnsavedChanges that referred to this.props by changing it to props - Change function name from `warnIfUnsavedChangesCaller` to `handleUnsavedChanges`, remove it being called via binding/arrow func --- client/modules/IDE/pages/IDEView.jsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 && }