Opened 5 hours ago
#37010 new New feature
Admin: improve filtered select feedback while filtering
| Reported by: | David Ansa | Owned by: | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | yes |
Description
The admin FilteredSelectMultiple / SelectFilter2 widget supports filtering large option lists, but its filtered state is hard to understand during bulk actions.
Current behavior
Filtering narrows the visible options in the "Available" and "Chosen" lists.
The widget does not show how many options remain visible after filtering.
The bulk buttons keep the labels "Choose all ..." and "Remove all ..." even when a filter is active.
In practice, those bulk actions operate on the displayed subset, which can be surprising when the label suggests that all options will be affected.
Clearing a filter requires manually deleting the filter text.
Proposed improvement
Show a live X of Y shown count next to the filter input while a filter is active.
Relabel bulk actions while filtering so they read:
Choose all displayed ...
Remove all displayed ...
Allow the active filter to be cleared with the Escape key.
Keep the filtered state and labels synchronized after moving options between the two lists.
Why this is useful
It makes filter_horizontal / filter_vertical easier to understand on large many-to-many lists.
It clarifies what bulk actions will do while the list is filtered.
It improves keyboard usability without changing the widget API.
Implementation notes
This can be implemented in django/contrib/admin/static/admin/js/SelectFilter2.js.
A small style hook is useful in django/contrib/admin/static/admin/css/widgets.css.
Regression coverage fits well in tests/admin_widgets/tests.py with Selenium tests around the filtered-select widget behavior.
Testing
Add Selenium coverage for:
live X of Y shown feedback when filtering
updated bulk-action labels while a filter is active
clearing filters with Escape
Relevant test command:
.\.venv\Scripts\python.exe tests\runtests.py admin_widgets.tests.HorizontalVerticalFilterSeleniumTests --selenium=chrome --parallel 1
Notes
I did a quick Trac search for existing SelectFilter2 / FilteredSelectMultiple tickets but did not find an obvious existing match for this exact UX improvement.
This looks small in scope, but it is a user-visible admin behavior change, so I am filing it before asking for review on the related PR.