Opened 31 hours ago
Last modified 19 hours ago
#36828 assigned Bug
Missing input labels (WCAG2.1)
| Reported by: | Johannes Maron | Owned by: | Youngkwang Yang |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | accessibility |
| Cc: | Johannes Maron, Antoliny | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Howdy,
I noticed Django sometimes replaces the label with a fieldset tag. However, input labels are required as of WCAG 2.1; see also: https://www.w3.org/TR/WCAG21/#labels-or-instructions
Since Django must be WCAG2.2 AAA compliant, we might even want to patch all supported versions. However, this would mean shipping a rendering change in a bugfix.
My current impulse would be to enforce labels for WCAG compliance in 6.1, since shipping a rendering change within a bug fix release might result into more issues for users.
Cheers!
Joe
Change History (9)
comment:1 by , 30 hours ago
| Keywords: | accessibility added |
|---|
comment:2 by , 30 hours ago
| Description: | modified (diff) |
|---|
comment:3 by , 30 hours ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:4 by , 30 hours ago
comment:5 by , 29 hours ago
Thanks! Yes, that does resolve half of the issue. We have correct HTML, but the WCAG violation remains.
comment:6 by , 29 hours ago
| Description: | modified (diff) |
|---|
comment:7 by , 29 hours ago
| Summary: | Django form fields render into invalid HTML → Missing input labels (WCAG2.1) |
|---|
comment:8 by , 22 hours ago
Thank you, Joe :)
Could you share an example of where the issue shows up?
My guess is that you’re referring to ClearableFileInput, which was recently switched to use a fieldset. When using the ClearableFileInput widget and an initial value is present, it appears that the input for changing the value does not have an associated label.
Since the original label was replaced by a legend, it seems that this part (the “changed” input) should now have an associated label.
Is this the case you had in mind?
comment:9 by , 21 hours ago
| Cc: | added |
|---|
This looks similar to #36724 (fixed in PR https://github.com/django/django/pull/20080).
could you check which version you're testing with?