summaryrefslogtreecommitdiffstats
path: root/ui/src/components/site-form.tsx
diff options
context:
space:
mode:
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 (
<>