From 4e8df588b9e31d22efa5da618256c392556ede05 Mon Sep 17 00:00:00 2001 From: Jason Park Date: Thu, 24 Jan 2019 01:10:58 -0500 Subject: [PATCH] Fix history block --- src/frontend/components/App/index.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/frontend/components/App/index.jsx b/src/frontend/components/App/index.jsx index 3358ea5..eebe295 100644 --- a/src/frontend/components/App/index.jsx +++ b/src/frontend/components/App/index.jsx @@ -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 {