Skip to content

Commit 4e8df58

Browse files
committed
Fix history block
1 parent 68c062f commit 4e8df58

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/frontend/components/App/index.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ class App extends BaseComponent {
7575

7676
toggleHistoryBlock(enable = !this.unblock) {
7777
if (enable) {
78-
const { saved } = this.props.current;
7978
const warningMessage = 'Are you sure you want to discard changes?';
80-
window.onbeforeunload = () => saved ? undefined : warningMessage;
79+
window.onbeforeunload = () => {
80+
const { saved } = this.props.current;
81+
if (!saved) return warningMessage;
82+
};
8183
this.unblock = this.props.history.block((location) => {
8284
if (location.pathname === this.props.location.pathname) return;
85+
const { saved } = this.props.current;
8386
if (!saved) return warningMessage;
8487
});
8588
} else {

0 commit comments

Comments
 (0)