Skip to content

Commit

Permalink
fix: warn unsaved form allow submit actions (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav authored Aug 20, 2024
1 parent 0071b61 commit 43ec771
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/unfold/static/unfold/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ const warnWithoutSaving = () => {

checkFormChanged();

window.addEventListener("beforeunload", (e) => {
preventLeaving = (e) => {
if (formChanged) {
e.preventDefault();
}
};

form.addEventListener("submit", (e) => {
window.removeEventListener("beforeunload", preventLeaving);
});

window.addEventListener("beforeunload", preventLeaving);
};

/*************************************************************
Expand Down

0 comments on commit 43ec771

Please sign in to comment.