Skip to content
This repository has been archived by the owner on Mar 23, 2022. It is now read-only.

Commit

Permalink
FIX - Unload dialog shown upon form publishing (#227)
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Aug 1, 2021
1 parent 339a243 commit 31285c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/elements/posts/shared/form/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const PostFormBase = <P extends PostMeta, R extends PostEditResponse>({
return () => {
window.onbeforeunload = null;
};
});
}, [formState]);

const setPayload = <K extends keyof P>(key: K, newValue: P[K]) => {
const payload: P = {...formState.payload, [key]: newValue};
Expand Down Expand Up @@ -83,11 +83,12 @@ export const PostFormBase = <P extends PostMeta, R extends PostEditResponse>({
const data = await fnSendRequest(formState.payload);

if (data.success) {
window.onbeforeunload = null;

if (onSubmitSuccess) {
onSubmitSuccess();
}

window.onbeforeunload = null;
dispatch(alertDispatchers.showAlert({
message: t((t) => t.posts.message.published),
variant: 'success',
Expand Down

0 comments on commit 31285c5

Please sign in to comment.