#36772: `aria-describedby`-Attribute missing from file field HTML in Django 6.0
-------------------------------------+-------------------------------------
     Reporter:  cessor               |                     Type:  Bug
       Status:  new                  |                Component:  Forms
      Version:  6.0                  |                 Severity:  Normal
     Keywords:  forms, aria,         |             Triage Stage:
  fieldset, accessibility, admin     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 In Django 6, input fields of type `file` do not render `aria-describedby`
 attributes. Those were introduced with Django 5.2. to facilitate use of
 screenreaders.

 == Steps to reproduce

  - Create a model with a `file = models.FileField(...)`
  - Render a `forms.ModelForm` for the model
  - The HTML for the input field should contain attribute `aria-
 describedby="id_file_helptext"`
  - When Django 5.2 is installed the attribute is rendered
  - When Django 6.0 is installed, the attribute is not rendered

 Note that this issue affects `FileFields` but not `CharFields`. Both
 render HTML input elements. I did not test whether other fields are also
 affected.

 I attached a zipfile with an example app. To reproduce the error, please
 create a .venv and install Django 5.2, then run `manage.py tests`; all
 will succeed. When installing Django 6, one test will fail. The module
 `web.tests` contains two tests, both check the input field HTML for `aria-
 describedby`, one is for a charfield, the other for a filefield.


 == Details

 Consider Issue #35892 "Supported Widget.use_fieldset in admin forms.". In
 the scope of this ticked, a change was made to
 `django.forms.widgets.ClearableFileInput`, where as with commit 4187da2
 the value `ClearableFileInput.use_fieldset` is set to `True` by default.

 Because of this change,
 `django.forms.boundfield.BoundField.build_widget_attrs` does not add the
 "aria-describedby" attribute to the `attrs` dictionary which is then
 missing from the final response HTML.

 Sources:
  -
 
https://github.com/django/django/blame/0ca3a0661173b02e2cbb0183d8543e790e7e4a55/django/forms/widgets.py#L533
  -
 
https://github.com/django/django/blob/0ca3a0661173b02e2cbb0183d8543e790e7e4a55/django/forms/boundfield.py#L300
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36772>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019ae920f0f7-200cfd6f-3e82-4fbc-b998-be686c654519-000000%40eu-central-1.amazonses.com.

Reply via email to