Skip to content

Commit 43ec771

Browse files
authored
fix: warn unsaved form allow submit actions (#692)
1 parent 0071b61 commit 43ec771

File tree

1 file changed

+7
-1
lines changed
  • src/unfold/static/unfold/js

1 file changed

+7
-1
lines changed

src/unfold/static/unfold/js/app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ const warnWithoutSaving = () => {
3939

4040
checkFormChanged();
4141

42-
window.addEventListener("beforeunload", (e) => {
42+
preventLeaving = (e) => {
4343
if (formChanged) {
4444
e.preventDefault();
4545
}
46+
};
47+
48+
form.addEventListener("submit", (e) => {
49+
window.removeEventListener("beforeunload", preventLeaving);
4650
});
51+
52+
window.addEventListener("beforeunload", preventLeaving);
4753
};
4854

4955
/*************************************************************

0 commit comments

Comments
 (0)