Leaving a page: a ticket's reply no longer asks Leave page first, as it is kept as a draft, and invoice, quote and recurring invoice notes save on the way out instead of asking; the document editor, signature and settings pages still ask

This commit is contained in:
johnnyq
2026-11-19 23:26:02 -05:00
parent 6a5bc6cf55
commit 3d2bfbcad5
4 changed files with 25 additions and 9 deletions

View File

@@ -1166,7 +1166,9 @@ itflowBindOnce('itflowCategoryAdd', 'click', '[data-category-add]', function ()
*
* Editors inside an open modal are skipped, as before: the modal is where that
* work gets submitted or discarded. Editors from a closed ajax modal are removed
* by js/ajax_modal.js, so tinymce.get() no longer returns them.
* by js/ajax_modal.js, so tinymce.get() no longer returns them. So is one whose
* text is kept as a draft (data-draft-kept - the ticket reply, agent/js/ticket_reply_extras.js),
* where leaving loses nothing.
*
* Flagged on window because modal_footer.php re-loads this file on every ajax
* modal open.
@@ -1179,7 +1181,8 @@ if (!window.itflowEditorUnloadGuard) {
}
const unsaved = tinymce.get().some(function (editor) {
const inVisibleModal = editor.getContainer()?.closest('.modal.show');
return !inVisibleModal && editor.isDirty();
const keptAsDraft = editor.getElement()?.dataset.draftKept === '1';
return !inVisibleModal && !keptAsDraft && editor.isDirty();
});
if (unsaved) {
e.preventDefault();