8000 Fixed #35507 -- Improved accessibility using a search landmark and aria-labelledby. by Antoliny0919 · Pull Request #19379 · django/django · GitHub
[go: up one dir, main page]

Skip to content

Fixed #35507 -- Improved accessibility using a search landmark and aria-labelledby. #19379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
4 changes: 2 additions & 2 deletions django/contrib/admin/templates/admin/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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>
Expand All @@ -87,7 +87,7 @@ <h2 id="changelist-filter-header">{% translate 'Filter' %}</h2>
</h3>{% endif %}
</div>{% endif %}
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
</nav>
</search>
{% endif %}
{% endblock %}
</div>
Expand Down
4 changes: 3 additions & 1 deletion django/contrib/admin/templates/admin/search_form.html
Original file line number Diff line number Diff line change
@@ -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 %}>
Expand Down
7 changes: 6 additions & 1 deletion tests/admin_changelist/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,12 @@ def test_search_role(self):
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):
Expand Down
9 changes: 6 additions & 3 deletions tests/admin_views/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ def test_limited_filter(self):
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(
Expand Down Expand Up @@ -930,7 +931,8 @@ def test_relation_spanning_filters(self):
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": {
Expand Down Expand Up @@ -1070,7 +1072,8 @@ def test_named_group_field_choices_filter(self):
)
self.assertContains(
response,
'<nav id="changelist-filter" aria-labelledby="changelist-filter-header">',
'<search id="changelist-filter" '
'aria-labelledby="changelist-filter-header">',
)
self.assertContains(
response,
Expand Down
0