mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
Blocking page refresh when forms are filled. Fixes #671
This commit is contained in:
parent
d720993141
commit
32d43b85b9
9
ui/src/components/comment-form.tsx
vendored
9
ui/src/components/comment-form.tsx
vendored
@ -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() {
|
componentWillUnmount() {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
window.onbeforeunload = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
14
ui/src/components/community-form.tsx
vendored
14
ui/src/components/community-form.tsx
vendored
@ -97,8 +97,22 @@ export class CommunityForm extends Component<
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (
|
||||||
|
!this.state.loading &&
|
||||||
|
(this.state.communityForm.name ||
|
||||||
|
this.state.communityForm.title ||
|
||||||
|
this.state.communityForm.description)
|
||||||
|
) {
|
||||||
|
window.onbeforeunload = () => true;
|
||||||
|
} else {
|
||||||
|
window.onbeforeunload = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
window.onbeforeunload = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
14
ui/src/components/post-form.tsx
vendored
14
ui/src/components/post-form.tsx
vendored
@ -151,8 +151,22 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||||||
setupTippy();
|
setupTippy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (
|
||||||
|
!this.state.loading &&
|
||||||
|
(this.state.postForm.name ||
|
||||||
|
this.state.postForm.url ||
|
||||||
|
this.state.postForm.body)
|
||||||
|
) {
|
||||||
|
window.onbeforeunload = () => true;
|
||||||
|
} else {
|
||||||
|
window.onbeforeunload = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
window.onbeforeunload = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
9
ui/src/components/private-message-form.tsx
vendored
9
ui/src/components/private-message-form.tsx
vendored
@ -110,8 +110,17 @@ export class PrivateMessageForm extends Component<
|
|||||||
setupTippy();
|
setupTippy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (!this.state.loading && this.state.privateMessageForm.content) {
|
||||||
|
window.onbeforeunload = () => true;
|
||||||
|
} else {
|
||||||
|
window.onbeforeunload = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
window.onbeforeunload = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
16
ui/src/components/site-form.tsx
vendored
16
ui/src/components/site-form.tsx
vendored
@ -64,6 +64,22 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||||||
this.setState(this.state);
|
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() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user