diff options
Diffstat (limited to 'ui/src/components/comment-form.tsx')
-rw-r--r-- | ui/src/components/comment-form.tsx | 9 |
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() { |