RelatedFieldWidgetWrapper links don’t convey their state for screen reader users
|Coen van der Kamp
|accessibility, screen reader
|Ready for checkin
|Patch needs improvement:
RelatedFieldWidgetWrapper have three links/buttons next to them to go to the Change/Add/View views for their model. Those links use a bit of JS to toggle whether the link is active or not based on whether the field has a value.
This link state (disabled/enabled) isn’t communicated to screen reader users in any way. We should be able to solve this by adding a
aria-disabled="true" attribute on those links when they are disabled (making sure to remove the attribute when the links are enabled).
- Template: https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/widgets/related_widget_wrapper.html
- And I believe the "link enabled/disabled" logic happens here: https://github.com/django/django/blob/main/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
_In addition_ this is unrelated but it’d be much nicer for screen reader users if the images within those links had
alt="". Right now the presence of
alt means screen reader users will hear "link, image, Change" – the fact there’s an image is completely irrelevant here. It’d be much better to instead have
link, Change selected <thing> (coming from the title attribute).