summaryrefslogtreecommitdiffstats
path: root/ui/src/components/comment-form.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-07-08 14:32:37 -0400
committerDessalines <tyhou13@gmx.com>2020-07-08 14:32:37 -0400
commit32d43b85b942e7b9d12b462a13c3dd52252acc6c (patch)
treec166b399e7e790bf07123343659a0c247c14f545 /ui/src/components/comment-form.tsx
parentd720993141cd941a5b724b38a675982f793d2f2c (diff)
Blocking page refresh when forms are filled. Fixes #671
Diffstat (limited to 'ui/src/components/comment-form.tsx')
-rw-r--r--ui/src/components/comment-form.tsx9
1 files changed, 9 insertions, 0 deletions
diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx
index 61ee3d77..770c127c 100644
--- a/ui/src/components/comment-form.tsx
+++ b/ui/src/components/comment-form.tsx
@@ -108,8 +108,17 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
});
}
+ componentDidUpdate() {
+ if (this.state.commentForm.content) {
+ window.onbeforeunload = () => true;
+ } else {
+ window.onbeforeunload = undefined;
+ }
+ }
+
componentWillUnmount() {
this.subscription.unsubscribe();
+ window.onbeforeunload = null;
}
render() {