Fix history block

This commit is contained in:
Jason Park
2019-01-24 01:10:58 -05:00
parent 68c062f4af
commit 4e8df588b9

View File

@@ -75,11 +75,14 @@ class App extends BaseComponent {
toggleHistoryBlock(enable = !this.unblock) {
if (enable) {
const { saved } = this.props.current;
const warningMessage = 'Are you sure you want to discard changes?';
window.onbeforeunload = () => saved ? undefined : warningMessage;
window.onbeforeunload = () => {
const { saved } = this.props.current;
if (!saved) return warningMessage;
};
this.unblock = this.props.history.block((location) => {
if (location.pathname === this.props.location.pathname) return;
const { saved } = this.props.current;
if (!saved) return warningMessage;
});
} else {