[#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
This commit is contained in:
parent
e666b46e7c
commit
decf4a9c4d
1 changed files with 5 additions and 7 deletions
|
@ -55,7 +55,7 @@ function warnIfUnsavedChanges(props) { // eslint-disable-line
|
||||||
props.persistState();
|
props.persistState();
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
} else if (props.ide.unsavedChanges) {
|
} else if (props.ide.unsavedChanges) {
|
||||||
if (!window.confirm(this.props.t('WarningUnsavedChanges'))) {
|
if (!window.confirm(props.t('WarningUnsavedChanges'))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
props.setUnsavedChanges(false);
|
props.setUnsavedChanges(false);
|
||||||
|
@ -90,9 +90,9 @@ class IDEView extends React.Component {
|
||||||
this.isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
|
this.isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
|
||||||
document.addEventListener('keydown', this.handleGlobalKeydown, false);
|
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;
|
this.autosaveInterval = null;
|
||||||
}
|
}
|
||||||
|
@ -205,9 +205,7 @@ class IDEView extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warnIfUnsavedChangesCaller(props) {
|
handleUnsavedChanges = () => warnIfUnsavedChanges(this.props);
|
||||||
return warnIfUnsavedChanges(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
@ -217,7 +215,7 @@ class IDEView extends React.Component {
|
||||||
</Helmet>
|
</Helmet>
|
||||||
{this.props.toast.isVisible && <Toast />}
|
{this.props.toast.isVisible && <Toast />}
|
||||||
<Nav
|
<Nav
|
||||||
warnIfUnsavedChanges={this.warnIfUnsavedChangesCaller.bind(this, this.props)}
|
warnIfUnsavedChanges={this.handleUnsavedChanges}
|
||||||
cmController={this.cmController}
|
cmController={this.cmController}
|
||||||
/>
|
/>
|
||||||
<Toolbar key={this.props.project.id} />
|
<Toolbar key={this.props.project.id} />
|
||||||
|
|
Loading…
Reference in a new issue