#36582: Accessibility improvement for required field labels for inline forms in 
the
admin.
--------------------------------------+------------------------------------
     Reporter:  Antoliny              |                    Owner:  Antoliny
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  contrib.admin         |                  Version:  5.2
     Severity:  Normal                |               Resolution:
     Keywords:  accessibility         |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  1
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):

 * stage:  Unreviewed => Accepted

Comment:

 Thanks for the analysis, Antoliny.

 I think Sarah's triage in comment:5 is still right.

 The undocumented `empty_permitted` parameter to `FormSet`—primarily used
 in the admin for inlines (see  ticket:16328#comment:2) but clearly in use
 elsewhere (see #28171)—expresses a concept that cannot be statically
 expressed with the HTML5 required attribute, since the semantic is more
 like "usually required, but not in case all other fields are also empty".

 > Should we consider adding another accessibility attribute to indicate
 required fields for assistive technologies?

 I think this would reduce to the same problem. "Required except sometimes
 not".

 I think Sarah is envisioning a change listener to remove/restore the
 `required` attribute depending on whether any field in an inline is non-
 empty.

 Depending on how this is implemented, we might have to revisit the
 exception added in #28171, since the following would no longer be invalid
 usage: you can manage it with javascript:

 {{{#!diff
 diff --git a/django/contrib/admin/options.py
 b/django/contrib/admin/options.py
 index 6c202c8e61..983716205c 100644
 --- a/django/contrib/admin/options.py
 +++ b/django/contrib/admin/options.py
 @@ -2294,6 +2294,7 @@ class ModelAdmin(BaseModelAdmin):
              "instance": obj,
              "prefix": prefix,
              "queryset": inline.get_queryset(request),
 +            "form_kwargs": { "empty_permitted": True,
 "use_required_attribute": True },
          }
          if request.method == "POST":
              formset_params.update(
 }}}
  Some details to work out there.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36582#comment:9>
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/0107019b09288049-cd9d15a6-a564-415d-9dda-d12194c5d38c-000000%40eu-central-1.amazonses.com.

Reply via email to