#36829 closed Bug (fixed)
ClearableFileInput.use_fieldset became True in Django 6.0
| Reported by: | Johannes Maron | Owned by: | Johannes Maron |
|---|---|---|---|
| Component: | Forms | Version: | 6.0 |
| Severity: | Release blocker | Keywords: | fieldset, legend |
| Cc: | Johannes Maron, Antoliny, David Smith | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | yes |
Description (last modified by )
Howdy y'all,
#35892 flipped django.forms.widgets.ClearableFileInput.use_fieldset from false to true.
The change can be found here: https://github.com/django/django/blame/4187da258fe212d494cb578a0bc2b52c4979ab95/django/forms/widgets.py#L533
This changes the form rendering outside the admin too. Probably just a small oversight and not an intentional change, since changes weren't accompanied by release notes.
Anyhow, both the input and the use_fieldset are part of the public documentation, and changes must undergo deprecation.
The problem gets amplified with #36828, since the current fieldset implementation violates HTML and WCAG 2.1
The only affected version is 6.0. I would recommend providing a regression patch in the next bugfix release.
Cheers!
Joe
Attachments (1)
Change History (17)
comment:1 by , 3 weeks ago
| Description: | modified (diff) |
|---|
comment:2 by , 3 weeks ago
comment:3 by , 3 weeks ago
Thank you for reporting this issue, Joe :)
In my view, using a fieldset for ClearableFileInput itself makes sense.
However, I also agree that it’s a problem that a change related to the admin affected form rendering outside of the admin as well (and that this wasn’t communicated).
As Tim suggested, should this change be limited to the admin only?
comment:4 by , 3 weeks ago
| Cc: | added |
|---|
comment:5 by , 3 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
Agreed, let's limit the change to the admin, since its widgets aren't publicly documented.
I'll attach a potential patch.
by , 3 weeks ago
| Attachment: | ticket-36829.patch added |
|---|
comment:6 by , 3 weeks ago
| Has patch: | set |
|---|
comment:7 by , 3 weeks ago
| Cc: | added |
|---|
Thanks for the report. I'm assuming that the change was intentional and regarded as a bugfix, which we don't document. I'm not certain whether we shouldn't just resolve this with a release note and versionchanged annotations.
Docs say:
when the widget contains multiple <input> tags such as ...
By that criterion, use_fieldset should be True here, modulo the configurability of required=True or no initial value causing the checkbox to not render.
The API stability policy mentions that minor changes may be necessary on upgrade. Johannes, can I ask what inconvenience this amounted to: have you authored a library that now has to fork on this behavior change?
David considered setting use_fieldset = True on ClearableFileInput from the get-go, but hesitated given the checkbox not being present if required=True or no initial value:
ClearableFiles render in different ways. It is possible to get a checkbox and a file field input with this one, and I wonder if we should be adding a fieldset in that scenario
and received mixed feedback:
I'm not sure fieldset is needed in that case, aria attributes here will be the aria-controlsand aria-label to know that there is a button action and the title of the action.
Based on a quick review, yes, I think it would make sense to have a fieldset for this, although it looks like the template would need further work (missing a label as well for the input?) so it’d warrant a more thorough review (and its own ticket).
... with the result that it was just tabled.
David, do you have any opinion about whether to retain this change as a bugfix?
comment:8 by , 3 weeks ago
| Keywords: | fieldset legend added |
|---|---|
| Summary: | Breaking change in ClearableFileInput → Missing release note and documentation for change to ClearableFileInput.use_fieldset |
comment:9 by , 2 weeks ago
I'll comment on this ticket and #36828 as a pair. In summary, my view is to:
- Keep this ticket to revert the change to
ClearableFileInputin Django 6.0 but keep it in the adminAdminFileWidget(i.e. implement Tim's comment). - Keep #36828 as a new feature to change the
ClearableFileInputtemplate to add<fieldset>and<legend>. This should be a new feature that can target 6.1 or later.
My reason for this suggestion is that #35892, which introduced this change, was specifically aimed at targeting the admin widget. The change to the default widget, as far as I can tell, was an unintended consequence of that change and needs further changes to the default template to make it work. Reverting the change to the default template, but keeping it in the admin, seems (but I've not specifically tried) like it would be a straight forward enough change to make.
This will allow us to take more time and to get feedback from the accessibility team before making changes to the default ClearableFileInput template. Especially as the accessibility team previously had mixed reviews on the change that would be required -- albeit that was some time ago.
comment:10 by , 2 weeks ago
Thanks, David. I think that's prudent. I'll review Johannes's PR implementing Tim's suggestion.
comment:11 by , 2 weeks ago
I dug around and found some prior ideation around providing a deprecation path for widget rendering changes. See ticket:32339#comment:2:
One issue we have is breaking peoples existing pages if we change the rendered HTML (so that CSS/JS selectors change for instance).
Can I point you to #31026, ... If we can get that in, then we'd be able to document a Use this template ... to restore the previous HTML, which then would give us room to introduce a more significant change.
Thanks Johannes for implementing #31026 years ago! :-)
Assuming something like that is possible here, I now agree this change would need to go through a deprecation path.
comment:12 by , 2 weeks ago
| Summary: | Missing release note and documentation for change to ClearableFileInput.use_fieldset → ClearableFileInput.use_fieldset became True in Django 6.0 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:13 by , 2 weeks ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:16 by , 5 days ago
Incidentally, this change also fixed #36772 which was originally closed as invalid.
It might be that only
AdminFileWidget(theClearableFileInputused in admin forms) should have that attribute.