From a67a69f95e268a679a6c42722240628019355790 Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Fri, 6 Mar 2020 14:57:52 -0500
Subject: Ask for confirmation on leaving pages with incomplete forms. Fixes
 #529

---
 ui/src/components/comment-form.tsx | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'ui/src/components/comment-form.tsx')

diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx
index aa8e651d..f3009d34 100644
--- a/ui/src/components/comment-form.tsx
+++ b/ui/src/components/comment-form.tsx
@@ -1,4 +1,5 @@
 import { Component, linkEvent } from 'inferno';
+import { Prompt } from 'inferno-router';
 import {
   CommentNode as CommentNodeI,
   CommentForm as CommentFormI,
@@ -87,6 +88,10 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
   render() {
     return (
       <div class="mb-3">
+        <Prompt
+          when={this.state.commentForm.content}
+          message={i18n.t('block_leaving')}
+        />
         <form onSubmit={linkEvent(this, this.handleCommentSubmit)}>
           <div class="form-group row">
             <div className={`col-sm-12`}>
-- 
cgit v1.2.3

