Fixed #33083 -- Fixed selecting all items in the admin changelist when actions are both top and bottom.

Thanks Benjamin Locher for the report.

Regression in 30e59705fc.
This commit is contained in:
Carlton Gibson 2021-09-21 19:58:00 +02:00 committed by GitHub
parent 7d909b2282
commit b0ed619303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 8 deletions

View File

@ -36,7 +36,10 @@
function clearAcross(options) { function clearAcross(options) {
reset(options); reset(options);
document.querySelector(options.acrossInput).value = 0; const acrossInputs = document.querySelectorAll(options.acrossInput);
acrossInputs.forEach(function(acrossInput) {
acrossInput.value = 0;
});
document.querySelector(options.actionContainer).classList.remove(options.selectedClass); document.querySelector(options.actionContainer).classList.remove(options.selectedClass);
} }
@ -107,8 +110,10 @@
document.querySelectorAll(options.acrossQuestions + " a").forEach(function(el) { document.querySelectorAll(options.acrossQuestions + " a").forEach(function(el) {
el.addEventListener('click', function(event) { el.addEventListener('click', function(event) {
event.preventDefault(); event.preventDefault();
const acrossInput = document.querySelector(options.acrossInput); const acrossInputs = document.querySelectorAll(options.acrossInput);
acrossInputs.forEach(function(acrossInput) {
acrossInput.value = 1; acrossInput.value = 1;
});
showClear(options); showClear(options);
}); });
}); });

View File

@ -11,3 +11,7 @@ Bugfixes
* Fixed a bug in Django 3.2 that caused incorrect links on read-only fields in * Fixed a bug in Django 3.2 that caused incorrect links on read-only fields in
admin (:ticket:`33077`). admin (:ticket:`33077`).
* Fixed a regression in Django 3.2 that caused incorrect selection of items
across all pages when actions were placed both on the top and bottom of the
admin change-list view (:ticket:`33083`).

View File

@ -134,6 +134,7 @@ class NoListDisplayLinksParentAdmin(admin.ModelAdmin):
list_display_links = None list_display_links = None
list_display = ['name'] list_display = ['name']
list_editable = ['name'] list_editable = ['name']
actions_on_bottom = True
site.register(Parent, NoListDisplayLinksParentAdmin) site.register(Parent, NoListDisplayLinksParentAdmin)

View File

@ -1481,12 +1481,13 @@ class SeleniumTests(AdminSeleniumTestCase):
question = self.selenium.find_element_by_css_selector('.actions > .question') question = self.selenium.find_element_by_css_selector('.actions > .question')
clear = self.selenium.find_element_by_css_selector('.actions > .clear') clear = self.selenium.find_element_by_css_selector('.actions > .clear')
select_all = self.selenium.find_element_by_id('action-toggle') select_all = self.selenium.find_element_by_id('action-toggle')
select_across = self.selenium.find_element_by_name('select_across') select_across = self.selenium.find_elements_by_name('select_across')
self.assertIs(question.is_displayed(), False) self.assertIs(question.is_displayed(), False)
self.assertIs(clear.is_displayed(), False) self.assertIs(clear.is_displayed(), False)
self.assertIs(select_all.get_property('checked'), False) self.assertIs(select_all.get_property('checked'), False)
self.assertEqual(select_across.get_property('value'), '0') for hidden_input in select_across:
self.assertEqual(hidden_input.get_property('value'), '0')
self.assertIs(selection_indicator.is_displayed(), True) self.assertIs(selection_indicator.is_displayed(), True)
self.assertEqual(selection_indicator.text, '0 of 100 selected') self.assertEqual(selection_indicator.text, '0 of 100 selected')
self.assertIs(select_all_indicator.is_displayed(), False) self.assertIs(select_all_indicator.is_displayed(), False)
@ -1495,7 +1496,8 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertIs(question.is_displayed(), True) self.assertIs(question.is_displayed(), True)
self.assertIs(clear.is_displayed(), False) self.assertIs(clear.is_displayed(), False)
self.assertIs(select_all.get_property('checked'), True) self.assertIs(select_all.get_property('checked'), True)
self.assertEqual(select_across.get_property('value'), '0') for hidden_input in select_across:
self.assertEqual(hidden_input.get_property('value'), '0')
self.assertIs(selection_indicator.is_displayed(), True) self.assertIs(selection_indicator.is_displayed(), True)
self.assertEqual(selection_indicator.text, '100 of 100 selected') self.assertEqual(selection_indicator.text, '100 of 100 selected')
self.assertIs(select_all_indicator.is_displayed(), False) self.assertIs(select_all_indicator.is_displayed(), False)
@ -1504,7 +1506,8 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertIs(question.is_displayed(), False) self.assertIs(question.is_displayed(), False)
self.assertIs(clear.is_displayed(), True) self.assertIs(clear.is_displayed(), True)
self.assertIs(select_all.get_property('checked'), True) self.assertIs(select_all.get_property('checked'), True)
self.assertEqual(select_across.get_property('value'), '1') for hidden_input in select_across:
self.assertEqual(hidden_input.get_property('value'), '1')
self.assertIs(selection_indicator.is_displayed(), False) self.assertIs(selection_indicator.is_displayed(), False)
self.assertIs(select_all_indicator.is_displayed(), True) self.assertIs(select_all_indicator.is_displayed(), True)
@ -1512,7 +1515,8 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertIs(question.is_displayed(), False) self.assertIs(question.is_displayed(), False)
self.assertIs(clear.is_displayed(), False) self.assertIs(clear.is_displayed(), False)
self.assertIs(select_all.get_property('checked'), False) self.assertIs(select_all.get_property('checked'), False)
self.assertEqual(select_across.get_property('value'), '0') for hidden_input in select_across:
self.assertEqual(hidden_input.get_property('value'), '0')
self.assertIs(selection_indicator.is_displayed(), True) self.assertIs(selection_indicator.is_displayed(), True)
self.assertEqual(selection_indicator.text, '0 of 100 selected') self.assertEqual(selection_indicator.text, '0 of 100 selected')
self.assertIs(select_all_indicator.is_displayed(), False) self.assertIs(select_all_indicator.is_displayed(), False)