﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36757	Add CSS class to ignore change event in list view	Jacob Rief	Ahmed Asar	"I am the author of the popular 3rd party library https://github.com/jrief/django-admin-sortable2 used in approximately 1.5% of all Django installations. It is used to sort the entries in the list view of the Django-Admin. There however is a problem: Whenever one reorders entries and immediatly afterwards attemps to delete an entry, an alert message pops up, warning the user about unsaved changes.
Please check this issue https://github.com/jrief/django-admin-sortable2/issues/397 for details.

The easiest solution to fix this would be to just ignore that change. By applying this simple patch:

{{{
--- a/django/contrib/admin/static/admin/js/actions.js
+++ b/django/contrib/admin/static/admin/js/actions.js
@@ -151,7 +151,7 @@
                     updateCounter(actionCheckboxes, options);
                     lastChecked = target;
                 } else {
-                    list_editable_changed = true;
+                    list_editable_changed = !target.classList.contains('ignore-list-changes');
                 }
             });
         });
}}}


this issue can be solved without causing any harm to other applications. I then would apply the CSS class `ignore-list-changes` to the `<tbody>` before dragging an entry and remove it afterwards. Btw., a few lines above, the CSS class `action-select` is used to prevent a similar use-case, so this patch follows the same logic.

This patch can also be used by other 3rd party libraries which change fields inside the list view and want to prevent such a warning message.

The class name `ignore-list-changes` is of course open for debate.

If this patch is accepted, I'll create a pull request."	New feature	closed	contrib.admin	dev	Normal	wontfix	list-view, change-event	Jacob Rief	Unreviewed	0	0	0	0	0	0
