1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #34834 -- Added role="search" to the admin changelist search form.

This commit is contained in:
Lemuel Sta Ana 2023-09-13 22:37:07 -04:00 committed by Mariusz Felisiak
parent e2a3a896cf
commit 969ecb8236
2 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{% load i18n static %}
{% if cl.search_fields %}
<div id="toolbar"><form id="changelist-search" method="get">
<div id="toolbar"><form id="changelist-search" method="get" role="search">
<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 %}>

View File

@ -1585,6 +1585,16 @@ class ChangeListTests(TestCase):
'aria-describedby="searchbar_helptext">',
)
def test_search_role(self):
m = BandAdmin(Band, custom_site)
m.search_fields = ["name"]
request = self._mocked_authenticated_request("/band/", self.superuser)
response = m.changelist_view(request)
self.assertContains(
response,
'<form id="changelist-search" method="get" role="search">',
)
def test_search_bar_total_link_preserves_options(self):
self.client.force_login(self.superuser)
url = reverse("admin:auth_user_changelist")