summaryrefslogtreecommitdiffstats
path: root/ui/src/components/site-form.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-07-11 19:12:56 -0400
committerDessalines <tyhou13@gmx.com>2020-07-11 19:12:56 -0400
commit60288b2d060ba930fe6cae22c4824d88fe7a00c9 (patch)
tree8fed01325853240c69f3688ee621be29bedfd382 /ui/src/components/site-form.tsx
parent1710844a1bc6a4f46eceaa12f2fb428cb794c694 (diff)
parent1b9f2fa5f7f7831f59b24cb36a5607a769a0d92e (diff)
Merge branch 'master' into jmarthernandez-remove-karma-from-search
Diffstat (limited to 'ui/src/components/site-form.tsx')
-rw-r--r--ui/src/components/site-form.tsx16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/src/components/site-form.tsx b/ui/src/components/site-form.tsx
index a51286c8..291251d3 100644
--- a/ui/src/components/site-form.tsx
+++ b/ui/src/components/site-form.tsx
@@ -64,6 +64,22 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
this.setState(this.state);
}
+ componentDidUpdate() {
+ if (
+ !this.state.loading &&
+ !this.props.site &&
+ (this.state.siteForm.name || this.state.siteForm.description)
+ ) {
+ window.onbeforeunload = () => true;
+ } else {
+ window.onbeforeunload = undefined;
+ }
+ }
+
+ componentWillUnmount() {
+ window.onbeforeunload = null;
+ }
+
render() {
return (
<>