提交 4e8df588 编写于 作者: J Jason Park

Fix history block

上级 68c062f4
...@@ -75,11 +75,14 @@ class App extends BaseComponent { ...@@ -75,11 +75,14 @@ class App extends BaseComponent {
toggleHistoryBlock(enable = !this.unblock) { toggleHistoryBlock(enable = !this.unblock) {
if (enable) { if (enable) {
const { saved } = this.props.current;
const warningMessage = 'Are you sure you want to discard changes?'; 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) => { this.unblock = this.props.history.block((location) => {
if (location.pathname === this.props.location.pathname) return; if (location.pathname === this.props.location.pathname) return;
const { saved } = this.props.current;
if (!saved) return warningMessage; if (!saved) return warningMessage;
}); });
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册