﻿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
36723	Dead JS code attempting to reposition FilteredSelectMultiple widget	Jacob Walls	Varun Kasyap Pentamaraju	"There is [https://github.com/django/django/blob/fffa64abc3870989d62659453cb302857c539956/django/contrib/admin/static/admin/js/SelectFilter2.js#L25-L30 code] in SelectFilter2.js that appears to reposition a help text for a `FilteredSelectMultiple` above the controls, but it doesn't work for two reasons:
- it searches for a help text in a `<p>` tag, but it became a `<div>` in #27207
- to find the wanted help text today, it now would need to start its search two parents higher (#34383 looks relevant, but I didn't verify if already an issue before that)

In other words, if we want this code to work, it would need to be like:

{{{#!diff
diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js
index 2100280220..beb50fb5e2 100644
--- a/django/contrib/admin/static/admin/js/SelectFilter2.js
+++ b/django/contrib/admin/static/admin/js/SelectFilter2.js
@@ -18,15 +18,16 @@ Requires core.js and SelectBox.js.
             from_box.setAttribute('aria-labelledby', field_id + '_from_label');
             from_box.setAttribute('aria-describedby', `${field_id}_helptext ${field_id}_choose_helptext`);
 
-            for (const p of from_box.parentNode.getElementsByTagName('p')) {
-                if (p.classList.contains(""info"")) {
-                    // Remove <p class=""info"">, because it just gets in the way.
-                    from_box.parentNode.removeChild(p);
-                } else if (p.classList.contains(""help"")) {
+            const parentOfFlexContainer = from_box.parentNode.parentElement.parentElement;
+            for (const div of parentOfFlexContainer.getElementsByTagName('div')) {
+                if (div.classList.contains(""info"")) {
+                    // Remove <div class=""info"">, because it just gets in the way.
+                    parentOfFlexContainer.removeChild(div);
+                } else if (div.classList.contains('help')) {
                     // Move help text up to the top so it isn't below the select
                     // boxes or wrapped off on the side to the right of the add
                     // button:
-                    from_box.parentNode.insertBefore(p, from_box.parentNode.firstChild);
+                    parentOfFlexContainer.insertBefore(div, parentOfFlexContainer.firstChild);
                 }
             }
 }}}

In order to have:
[[Image(patch.png)]].

Rather than:
[[Image(main.png)]].

To reproduce, just visit the admin, edit a user, view the permissions select widget, observe placement of the help text."	Cleanup/optimization	closed	contrib.admin	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	1
