summaryrefslogtreecommitdiffstats
path: root/ui/src/components/site-form.tsx
diff options
context:
space:
mode:
authorFilip785 <fdjuricic98@gmail.com>2020-07-08 22:15:34 +0200
committerFilip785 <fdjuricic98@gmail.com>2020-07-08 22:15:34 +0200
commitabdbd50f5edb03917fc0cd770ad1f9f44f5b8980 (patch)
tree1309f79fabe87f940d799f5ae3ba580002240526 /ui/src/components/site-form.tsx
parent8fe8836bc263be11895fafa958409499c9e9fc9d (diff)
parent32d43b85b942e7b9d12b462a13c3dd52252acc6c (diff)
Merge remote-tracking branch 'upstream/master' into cake-day
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 (
<>