diff options
author | Dessalines <tyhou13@gmx.com> | 2020-03-06 14:57:52 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-03-06 14:57:52 -0500 |
commit | a67a69f95e268a679a6c42722240628019355790 (patch) | |
tree | 5e7334cb89e4e69d547e90ccba7864bd0f62fc19 /ui/src/components/post-form.tsx | |
parent | 0708a6d665ef81700ac61c32f1c3710db9493108 (diff) |
Ask for confirmation on leaving pages with incomplete forms. Fixes #529
Diffstat (limited to 'ui/src/components/post-form.tsx')
-rw-r--r-- | ui/src/components/post-form.tsx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index ef25a546..5f05bd58 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -1,4 +1,5 @@ import { Component, linkEvent } from 'inferno'; +import { Prompt } from 'inferno-router'; import { PostListings } from './post-listings'; import { Subscription } from 'rxjs'; import { retryWhen, delay, take } from 'rxjs/operators'; @@ -153,6 +154,15 @@ export class PostForm extends Component<PostFormProps, PostFormState> { render() { return ( <div> + <Prompt + when={ + !this.state.loading && + (this.state.postForm.name || + this.state.postForm.url || + this.state.postForm.body) + } + message={i18n.t('block_leaving')} + /> <form onSubmit={linkEvent(this, this.handlePostSubmit)}> <div class="form-group row"> <label class="col-sm-2 col-form-label" htmlFor="post-url"> |