Skip to content

Conversation

erosselli
Copy link
Contributor

@erosselli erosselli commented Oct 20, 2023

Problem

Fixed #34909.

In the Admin home page that lists your apps and their models (see screenshot below), there is an Add and a Change button for each model. All these buttons had the same accessible name, "Add" and "Change" respectively. This could be confusing for users using screen readers, since all the buttons would be called the same. It's better if the screen reader reads out something like "Add <model-name>" instead of just "Add", so that it's clearer for the user what they're adding or changing. See accessible naming guidelines for more information on this topic.

Alternative option

Adding something like aria-label="Add <model-name>" to the buttons would fix the issue for screen reader users, but could impact the experience of voice control users. An example of this is that a user could use voice control saying something like "Click Add", but because the Add button now has a "hidden" name that's different (Add <model-name>), the voice control might not recognize this button when the user says "Click Add". This kind of issue is explained in more detail in this post about voice control usability considerations.

Implemented solution

The implemented fix was to use aria-describedby with a reference to the model name, so that screen reader users can hear something like "Add" followed by the model name after a brief pause, while the accessible name of the button remains Add and voice control users are not affected. This fix was tested using both the Mac VoiceOver utility and the Mac Voice Control utility (both in Ventura 13.4).

The Admin screens that were updated are the following:
Screenshot of Django Admin homepage
Screenshot of Django Admin page that lists all models for a specific app

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello! Thank you for your contribution 💪

As it's your first contribution be sure to check out the patch review checklist.

If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!

If you have any design or process questions then you can ask in the Django forum.

Welcome aboard ⛵️!

@felixxm felixxm requested a review from a team October 20, 2023 15:09
@erosselli erosselli force-pushed the ticket_34909 branch 2 times, most recently from a17d748 to 0fef9cc Compare October 20, 2023 19:40
@nessita
Copy link
Contributor

nessita commented Oct 30, 2023

Thank you @erosselli for this work!

I have one question: when a user using the voice control system says Click Add, and there are multiple Add links, which one does the system chooses?

Separately, I would suggest that one or two extra tests are added covering the new structure of the th and the adding of the new aria-describedby attributes.

I'll be marking the ticket as "patch needs improvement", but please once you push these changes, please unset the ticket flags "patch needs improvement" and "patch needs tests" so it shows again in the review queue.

@erosselli
Copy link
Contributor Author

Hi @nessita , when using voice control, all actionable items will be numbered. When you say something like "Click Add", it will number the buttons that matched the name (in this case "Add"), and you can then say the number of the button you want to click. See screenshot below
I'll work on adding the missing tests.
Screenshot 2023-10-30 at 17 44 53

@erosselli
Copy link
Contributor Author

@nessita I have added a test for the accessible button names

@knyghty knyghty self-requested a review November 16, 2023 19:31
@nessita
Copy link
Contributor

nessita commented Nov 22, 2023

@nessita I have added a test for the accessible button names

Thank you @erosselli! The branch looks great. Question: could we use a more verbose th id such as "{{ app.app_label }}-{{ model.object_name|lower }}"? Would this affect the general outcome in any way?

(From my understanding of how aria-describedby works, this should work, but I wanted to double check with you.)

@erosselli
Copy link
Contributor Author

Hi @nessita , I think it should work, as long as model.object_name does not have any whitespaces, which I think it shouldn't right? If it does have spaces, that would affect the meaning of aria-describedby , since it would be aria-described-by="first_word second_word" and that would be interpreted as two separate ids .

@nessita nessita added the selenium Apply to have Selenium tests run on a PR label Dec 13, 2023
@nessita
Copy link
Contributor

nessita commented Dec 13, 2023

I'm unable to reproduce the Selenium issue locally and it seems quite unrelated to this change.

@felixxm felixxm changed the title Fixed #34909 -- Added aria-describedby to Admin Add/Change buttons Fixed #34909 -- Associated buttons in admin navigation sidebar with row descriptions. Dec 15, 2023
@felixxm felixxm changed the title Fixed #34909 -- Associated buttons in admin navigation sidebar with row descriptions. Fixed #34909 -- Associated links in admin navigation sidebar with row descriptions. Dec 15, 2023
@felixxm
Copy link
Member

felixxm commented Dec 15, 2023

@erosselli Thanks 👍 Welcome aboard ⛵

I made small edits to tests, pushed template refactoring to a separate commit.

@nessita
Copy link
Contributor

nessita commented Dec 15, 2023

@felixxm yesterday I've pinged the Accessibility team for a review and they will complete it soon, so the merging should wait until then. Thanks!

@felixxm
Copy link
Member

felixxm commented Dec 15, 2023

@felixxm yesterday I've pinged the Accessibility team for a review and they will complete it soon, so the merging should wait until then. Thanks!

I know, have you seen my comment on Discord? I don't think we need another round of manual accessibility tests, I'm going to merge it today or tomorrow.

@nessita
Copy link
Contributor

nessita commented Dec 15, 2023

@felixxm yesterday I've pinged the Accessibility team for a review and they will complete it soon, so the merging should wait until then. Thanks!

I know, have you seen my comment on Discord?

I didn't before, now I did :-)

I don't think we need another round of manual accessibility tests, I'm going to merge it today or tomorrow.

Ok, thanks.

Eliana Rosselli and others added 2 commits December 15, 2023 21:01
… descriptions.

This adds aria-describedby attribute to the models' links in the admin
navigation sidebar.

Thanks Thibaud Colas for the review.

Co-authored-by: Dara Silvera <[email protected]>
@felixxm felixxm merged commit c83c639 into django:main Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DjangoCon 🦄 selenium Apply to have Selenium tests run on a PR

Projects

Development

Successfully merging this pull request may close these issues.

3 participants