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

Conversation

Antoliny0919
Copy link
Contributor
@Antoliny0919 Antoliny0919 commented Apr 13, 2025

Trac ticket number

ticket-35507

Branch description

Continue icastellanox's PR

I have added a label to the admin search-form following the work in #18256. As suggested by MHLut, we improve accessibility by using aria-labelledby to add elements that are not visually visible but can be heard by screen reader users.

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.

@sarahboyce sarahboyce added selenium Apply to have Selenium tests run on a PR screenshots 🖼️ labels Apr 15, 2025
@sarahboyce sarahboyce requested a review from a team April 15, 2025 08:30
@Antoliny0919 Antoliny0919 force-pushed the ticket_35507 branch 2 times, most recently from a587d8b to 9fb562d Compare April 17, 2025 04:18
@thibaudcolas
Copy link
Member

Thank you @Antoliny0919! Static preview of this PR in my demo site: PR preview - Admin - Releases changelist. Can’t review just yet but changes looking reasonable. If you have the chance in the future be great for you to state in the description how exactly we’re continuing from #18256, in particular how the recommended changes there have been addressed in your new version.

cc @tut-tuuut if you can review.

@Antoliny0919
Copy link
Contributor Author

Hello @thibaudcolas 🙌 I have a question regarding accessibility.
When using Django admin pagination with a screen reader like voiceover, it currently announces the innerHTML (e.g., a page number) and the role, such as “button.”

Screenshot 2025-05-03 at 9 57 46 AM

However, I'm wondering if this information alone is sufficient for screen reader users to clearly understand what action each pagination button performs. For example, a button labeled “2” might not clearly communicate that it navigates to page 2.

Could this be considered an area for potential accessibility improvement?
(Of course, I might be misunderstanding things since I haven't used a screen reader much.)

@tut-tuuut
Copy link

Yes @Antoliny0919 you are right, there is room for improvement here on the paginations!

Inspiration is in W3C's and UK's design systems, what I would do in summary:

  • wrap the pagination in a <nav> with an accurate label provided by an aria-labelledby;
  • label each page link with "page x" using an aria-label or an visually hidden element;
  • mark the current page with aria-current="page".

Copy link
@tut-tuuut tut-tuuut left a comment

Choose a reason for hiding this comment

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

Looks good to me, except for the redundant sr-only class.


/* ACCESSIBILITY */

.sr-only {

Choose a reason for hiding this comment

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

You don't need to add this class .sr-only, it does the same as .visually-hidden just above, which is already used in the admin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn’t realize there was a class doing the same thing right above. Thank you so much tut-tuuut :)

@@ -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="sr-only">{% blocktranslate with name=cl.opts.verbose_name_plural %}Search {{ name }}{% endblocktranslate %}</h2>

Choose a reason for hiding this comment

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

Suggested change
<h2 id="changelist-search-form" class="sr-only">{% blocktranslate with name=cl.opts.verbose_name_plural %}Search {{ name }}{% endblocktranslate %}</h2>
<h2 id="changelist-search-form" class="visually-hidden">{% blocktranslate with name=cl.opts.verbose_name_plural %}Search {{ name }}{% endblocktranslate %}</h2>

@Antoliny0919 Antoliny0919 force-pushed the ticket_35507 branch 2 times, most recently from 1a0e5cf to 469c694 Compare May 4, 2025 02:23
@Antoliny0919
Copy link
Contributor Author

Yes @Antoliny0919 you are right, there is room for improvement here on the paginations!

Inspiration is in W3C's and UK's design systems, what I would do in summary:

* wrap the pagination in a `<nav>` with an accurate label provided by an aria-labelledby;

* label each page link with "page x" using an aria-label or an visually hidden element;

* mark the current page with `aria-current="page"`.

Thank you for the great suggestion @tut-tuuut 💪
After incorporating the changes you recommended, I tested it with a screen reader.
When reaching the pagination area and navigating with the buttons, the following messages were announced.

Pagination Area

Screenshot 2025-05-04 at 11 27 53 AM

Pagination Button

Screenshot 2025-05-04 at 11 28 05 AM

With this change, I believe screen reader users will now be able to clearly understand when they reach the pagination area and what each button within the pagination represents.

@Antoliny0919
Copy link
Contributor Author
Screenshot 2025-05-04 at 4 56 57 PM

When accessing the area generated by date_hierarchy with a screen reader, it only announces it as “navigation.”
I believe this area also has room for accessibility improvement by using aria-labelledby to explain the purpose of the section more clearly.

It seems that there are still many parts that lack accessibility considerations.
In that sense, I feel this task requires a lot of research. 🧐

Since I’m not someone who uses a screen reader myself, there’s a chance I might not be able to fully assess whether certain parts truly have accessibility issues, even after doing some research.
For now, I’ll try to investigate as much as I can during my available time and look for areas that could benefit from accessibility improvements.

Once I’ve organized my findings, would it be okay if I request a review again? @tut-tuuut

@tut-tuuut
Copy link

I agree, there is a loooong way ahead of us. I think the best would be to create a lot of tiny PRs in order not to get lost in the mass of "one more thing". The accessibility of pagination could already be moved into a dedicated PR in my opinion: I have more pagination-related improvement ideas but the original PR which adds landmarks is already good.

@Antoliny0919
Copy link
Contributor Author

I agree, there is a loooong way ahead of us. I think the best would be to create a lot of tiny PRs in order not to get lost in the mass of "one more thing". The accessibility of pagination could already be moved into a dedicated PR in my opinion: I have more pagination-related improvement ideas but the original PR which adds landmarks is already good.

I agree.
In that case, I’ll move the pagination-related work to a separate PR.
Thank you so much for all your help 🥰
Would it be okay if I mention you when requesting a review related to accessibility?

@tut-tuuut
Copy link

Would it be okay if I mention you when requesting a review related to accessibility?

Yes please! 🥰

Copy link
Contributor
@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

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

Minor nit-picks, otherwise looks good to me!

Copy link
Contributor
@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

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

Thank you!

@sarahboyce sarahboyce merged commit 8bc3dd8 into django:main May 14, 2025
12 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DjangoCon Europe 🏰 screenshots 🖼️ selenium Apply to have Selenium tests run on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0