@ -108,8 +108,17 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
});
}
componentDidUpdate() {
if (this.state.commentForm.content) {
window.onbeforeunload = () => true;
} else {
window.onbeforeunload = undefined;
componentWillUnmount() {
this.subscription.unsubscribe();
window.onbeforeunload = null;
render() {
@ -97,8 +97,22 @@ export class CommunityForm extends Component<
if (
!this.state.loading &&
(this.state.communityForm.name ||
this.state.communityForm.title ||
this.state.communityForm.description)
) {
@ -151,8 +151,22 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
setupTippy();
(this.state.postForm.name ||
this.state.postForm.url ||
this.state.postForm.body)
@ -110,8 +110,17 @@ export class PrivateMessageForm extends Component<
if (!this.state.loading && this.state.privateMessageForm.content) {
@ -64,6 +64,22 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
this.setState(this.state);
!this.props.site &&
(this.state.siteForm.name || this.state.siteForm.description)
return (
<>