mirror of
https://github.com/django/django.git
synced 2025-07-03 17:29:12 +00:00
Fixed #35507 -- Improved accessibility of search and filter elements in the admin changelist.
This commit is contained in:
parent
8638d8bf74
commit
8bc3dd8727
@ -74,7 +74,7 @@
|
||||
</div>
|
||||
{% block filters %}
|
||||
{% if cl.has_filters %}
|
||||
<nav id="changelist-filter" aria-labelledby="changelist-filter-header">
|
||||
<search id="changelist-filter" aria-labelledby="changelist-filter-header">
|
||||
<h2 id="changelist-filter-header">{% translate 'Filter' %}</h2>
|
||||
{% if cl.is_facets_optional or cl.has_active_filters %}<div id="changelist-filter-extra-actions">
|
||||
{% if cl.is_facets_optional %}<h3>
|
||||
@ -86,7 +86,7 @@
|
||||
</h3>{% endif %}
|
||||
</div>{% endif %}
|
||||
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
|
||||
</nav>
|
||||
</search>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
@ -1,6 +1,8 @@
|
||||
{% load i18n static %}
|
||||
{% if cl.search_fields %}
|
||||
<div id="toolbar"><form id="changelist-search" method="get" role="search">
|
||||
<div id="toolbar">
|
||||
<h2 id="changelist-search-form" class="visually-hidden">{% blocktranslate with name=cl.opts.verbose_name_plural %}Search {{ name }}{% endblocktranslate %}</h2>
|
||||
<form id="changelist-search" method="get" role="search" aria-labelledby="changelist-search-form">
|
||||
<div><!-- DIV needed for valid HTML -->
|
||||
<label for="searchbar"><img src="{% static "admin/img/search.svg" %}" alt="Search"></label>
|
||||
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar"{% if cl.search_help_text %} aria-describedby="searchbar_helptext"{% endif %}>
|
||||
|
@ -1745,7 +1745,12 @@ class ChangeListTests(TestCase):
|
||||
response = m.changelist_view(request)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<form id="changelist-search" method="get" role="search">',
|
||||
'<h2 id="changelist-search-form" class="visually-hidden">Search bands</h2>',
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<form id="changelist-search" method="get" role="search" '
|
||||
'aria-labelledby="changelist-search-form">',
|
||||
)
|
||||
|
||||
def test_search_bar_total_link_preserves_options(self):
|
||||
|
@ -875,7 +875,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
response = self.client.get(reverse("admin:admin_views_thing_changelist"))
|
||||
self.assertContains(
|
||||
response,
|
||||
'<nav id="changelist-filter" aria-labelledby="changelist-filter-header">',
|
||||
'<search id="changelist-filter" '
|
||||
'aria-labelledby="changelist-filter-header">',
|
||||
msg_prefix="Expected filter not found in changelist view",
|
||||
)
|
||||
self.assertNotContains(
|
||||
@ -930,7 +931,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
response = self.client.get(changelist_url)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<nav id="changelist-filter" aria-labelledby="changelist-filter-header">',
|
||||
'<search id="changelist-filter" '
|
||||
'aria-labelledby="changelist-filter-header">',
|
||||
)
|
||||
filters = {
|
||||
"chap__id__exact": {
|
||||
@ -1070,7 +1072,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<nav id="changelist-filter" aria-labelledby="changelist-filter-header">',
|
||||
'<search id="changelist-filter" '
|
||||
'aria-labelledby="changelist-filter-header">',
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
|
Loading…
x
Reference in New Issue
Block a user