Fix confirmation for unsaved form changes (#5451)

This commit is contained in:
Yuriy Bakhtin 2021-11-30 16:15:55 +03:00 committed by GitHub
parent 73dfa058cf
commit 603dafa42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -395,13 +395,8 @@ humhub.module('client', function (module, require, $) {
});
var confirmFormChanges = function (evt, message) {
var form = $(evt.target).find('form');
if (!form.length) {
return;
}
if (unloadForm(form, message)) {
form.data('state', null);
if (unloadForm($form, message)) {
$form.resetChanges();
} else {
evt.preventDefault();
}
@ -412,7 +407,9 @@ humhub.module('client', function (module, require, $) {
});
$(document).on('hide.bs.modal', '.modal', function (evt) {
confirmFormChanges(evt, msgModal);
if ($form.closest('.modal').length) {
confirmFormChanges(evt, msgModal);
}
});
};