8000 Fixed #36366 -- accessibility improvements to the admin pagination ar… · django/django@3dfdbdf · GitHub
[go: up one dir, main page]

Skip to content

Commit 3dfdbdf

Browse files
committed
Fixed #36366 -- accessibility improvements to the admin pagination area using aria attributes
1 parent 825ddda commit 3dfdbdf

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

django/contrib/admin/templates/admin/object_history.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,21 @@
3434
{% endfor %}
3535
</tbody>
3636
</table>
37-
<p class="paginator">
37+
<nav class="paginator" aria-labelledby="pagination">
38+
<h2 id="pagination" class="visually-hidden">{% blocktranslate with name=opts.verbose_name %}Pagination {{ name }} entries{% endblocktranslate %}</h2>
3839
{% if pagination_required %}
3940
{% for i in page_range %}
4041
{% if i == action_list.paginator.ELLIPSIS %}
4142
{{ action_list.paginator.ELLIPSIS }}
4243
{% elif i == action_list.number %}
43-
<span class="this-page">{{ i }}</span>
44+
<span class="this-page" aria-current="page">{{ i }}</span>
4445
{% else %}
45-
<a role="button" href="?{{ page_var }}={{ i }}" {% if i == action_list.paginator.num_pages %} class="end" {% endif %}>{{ i }}</a>
46+
<a role="button" href="?{{ page_var }}={{ i }}" aria-label="page {{ i }}" {% if i == action_list.paginator.num_pages %} class="end" {% endif %}>{{ i }}</a>
4647
{% endif %}
4748
{% endfor %}
4849
{% endif %}
4950
{{ action_list.paginator.count }} {% blocktranslate count counter=action_list.paginator.count %}entry{% plural %}entries{% endblocktranslate %}
50-
</p>
51+
</nav>
5152
{% else %}
5253
<p>{% translate 'This object doesn’t have a change history. It probably wasn’t added via this admin site.' %}</p>
5354
{% endif %}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% load admin_list %}
22
{% load i18n %}
3-
<p class="paginator">
3+
<nav class="paginator" aria-labelledby="pagination">
4+
<h2 id="pagination" class="visually-hidden">{% blocktranslate with name=cl.opts.verbose_name_plural %}Pagination {{ name }}{% endblocktranslate %}</h2>
45
{% if pagination_required %}
56
{% for i in page_range %}
67
{% paginator_number cl i %}
@@ -9,4 +10,4 @@
910
{{ cl.result_count }} {% if cl.result_count == 1 %}{{ cl.opts.verbose_name }}{% else %}{{ cl.opts.verbose_name_plural }}{% endif %}
1011
{% if show_all_url %}<a href="{{ show_all_url }}" class="showall">{% translate 'Show all' %}</a>{% endif %}
1112
{% if cl.formset and cl.result_count %}<input type="submit" name="_save" class="default" value="{% translate 'Save' %}">{% endif %}
12-
</p>
13+
</nav>

django/contrib/admin/templatetags/admin_list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ def paginator_number(cl, i):
4242
if i == cl.paginator.ELLIPSIS:
4343
return format_html("{} ", cl.paginator.ELLIPSIS)
4444
elif i == cl.page_num:
45-
return format_html('<span class="this-page">{}</span> ', i)
45+
return format_html('<span class="this-page" aria-current="page">{}</span> ', i)
4646
else:
4747
return format_html(
48-
'<a role="button" href="{}"{}>{}</a> ',
48+
'<a role="button" href="{}" aria-label="page {}" {}>{}</a> ',
4949
cl.get_query_string({PAGE_VAR: i}),
50+
i,
5051
mark_safe(' class="end"' if i == cl.paginator.num_pages else ""),
5152
i,
5253
)

0 commit comments

Comments
 (0)
0