8000 Fixed #36366 -- Accessibility improvements to the admin pagination area using aria attributes. by Antoliny0919 · Pull Request #19448 · django/django · GitHub
[go: up one dir, main page]

Skip to content

Fixed #36366 -- Accessibility improvements to the admin pagination area using aria attributes. #19448

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Antoliny0919
Copy link
Contributor

Trac ticket number

ticket-36366

Branch description

Using aria attributes, I added descriptive information for screen readers when accessing the admin pagination area and its elements.


when accessing the pagination area...

Screenshot 2025-05-08 at 7 30 52 PM

when accessing the pagination button...

Screenshot 2025-05-08 at 7 39 46 PM

screen reader user's can identify the currently active page using aria-current.

Screenshot 2025-05-08 at 7 41 07 PM

By adding "Page XX" to the buttons within the pagination, we clarify that they are used to navigate between pages.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

@Antoliny0919 Antoliny0919 changed the title Fixed #36366 -- accessibility improvements to the admin pagination area using aria attributes. Fixed #36366 -- Accessibility improvements to the admin pagination area using aria attributes. May 12, 2025
@tut-tuuut
Copy link

oh hello

{% else %}
<a role="button" href="?{{ page_var }}={{ i }}" {% if i == action_list.paginator.num_pages %} class="end" {% endif %}>{{ i }}</a>
<a role="button" href="?{{ page_var }}={{ i }}" aria-label="page {{ i }}" {% if i == action_list.paginator.num_pages %} class="end" {% endif %}>{{ i }}</a>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are here, could we remove these role="button" from these links?

I know they have been added to remove the underline. But adding this attribute will change the "promise" and the expectations of screen reader users. A button does not (always) activate the same way as a link when using a keyboard; and you don't necessarily expect a complete reload of the page when you activate a button. So here we changed the semantics just for visual purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably need separate new ticket. Would you be willing to open it, @tut-tuuut

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, I added underlines to links in the main content area.
At that time, I removed the underline from links that didn’t need it by adding role="button".
As you pointed out, I clearly didn’t take accessibility into account.

Since screen reader users will hear it announced as a “button,” it could lead to unexpected behavior.
Moreover, since it's still fundamentally an anchor (a) tag, the spacebar won’t activate it either.

Thank you for pointing that out @tut-tuuut .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cliff688 , I’ve created the new ticket.
(Apologies for not being able to follow up on the task we discussed via email earlier.
For now, I’ll focus on resolving the tickets currently assigned to me. 😥)

Comment on lines 37 to 38
<nav class="paginator" aria-labelledby="pagination">
<h2 id="pagination" class="visually-hidden">Pagination</h2>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question @tut-tuuut 😃.

Currently, only the word "pagination" is provided as a screen reader.
I'm wondering if it would be better to include the model name before it.
It might be too much information, but at the same time, I’m concerned that when screen reader users navigate to the pagination area, the word "pagination" alone may not clearly indicate which model's pagination it is.
(It's not that they won’t know, but rather that they would have to keep track of which model it refers to.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's useful with only one pagination per page. (But on the other hand, explicit is better than implicit!)
I'm not sure if it's possible to have several paginations on only one page? I'm trying to make it happen on my test django instance ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @tut-tuuut
In theory, customize the admin page, we can place multiple paginations on a single page, but I think such cases are rare.

Previously, when we improved the accessibility of the search section, we included the module_name in that part.

As you mentioned, I also think that explicit is better than implicit.

@Antoliny0919 Antoliny0919 force-pushed the ticket_36366 branch 2 times, most recently from cb82fd4 to 3dfdbdf Compare May 18, 2025 09:23
@Antoliny0919
Copy link
Contributor Author
Antoliny0919 commented May 24, 2025

I have a suggestion.
How about using <ul> and <li> elements in the pagination area as well?
By applying <ul> and <li>, screen reader users can better understand how many items are present, which I think would be more helpful for accessibility.

{% if pagination_required %}
<ul>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the lag, but yes, very good idea to add the ul/li here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's totally fine, @tut-tuuut! I'm always grateful.

Comment on lines +37 to +38
<nav class="paginator" aria-labelledby="pagination">
<h2 id="pagination" class="visually-hidden">{% blocktranslate with name=opts.verbose_name %}Pagination {{ name }} entries{% endblocktranslate %}</h2>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since screen readers allow users to navigate to both the nav tag and the h2 tag in sequence, it seems that the descriptions provided are essentially redundant.

What do you think about removing the h2 tag and providing an aria-label on the nav element instead?

While this would mean giving up the heading semantics(translation), I think it might provide a more natural experience when navigating with a screen reader.

Sign up for free to jo 6D41 in this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants
0