diff --git a/framework/core/js/forum/src/components/composer-body.js b/framework/core/js/forum/src/components/composer-body.js index 71dab79be..631548222 100644 --- a/framework/core/js/forum/src/components/composer-body.js +++ b/framework/core/js/forum/src/components/composer-body.js @@ -49,7 +49,7 @@ export default class ComposerBody extends Component { } preventExit() { - return this.content() && this.content() != this.props.originalContent && !confirm(this.props.confirmExit); + return this.content() && this.content() != this.props.originalContent && this.props.confirmExit; } onsubmit(value) { diff --git a/framework/core/js/forum/src/components/composer.js b/framework/core/js/forum/src/components/composer.js index 609eb2a8f..84729ab3b 100644 --- a/framework/core/js/forum/src/components/composer.js +++ b/framework/core/js/forum/src/components/composer.js @@ -70,6 +70,10 @@ class Composer extends Component { $(document) .on('mousemove', this.handlers.onmousemove = this.onmousemove.bind(this)) .on('mouseup', this.handlers.onmouseup = this.onmouseup.bind(this)); + + window.onbeforeunload = e => { + return this.component && this.component.preventExit(); + }; } configHandle(element, isInitialized) { @@ -129,7 +133,12 @@ class Composer extends Component { } preventExit() { - return this.component && this.component.preventExit(); + if (this.component) { + var preventExit = this.component.preventExit(); + if (preventExit) { + return !confirm(preventExit); + } + } } render(anchorToBottom) { diff --git a/framework/core/js/forum/src/components/discussion-composer.js b/framework/core/js/forum/src/components/discussion-composer.js index e6b76de38..8197fe5e1 100644 --- a/framework/core/js/forum/src/components/discussion-composer.js +++ b/framework/core/js/forum/src/components/discussion-composer.js @@ -68,7 +68,7 @@ export default class DiscussionComposer extends ComposerBody { } preventExit() { - return (this.title() || this.content()) && !confirm(this.props.confirmExit); + return (this.title() || this.content()) && this.props.confirmExit; } data() {