#34488 closed Cleanup/optimization (fixed)
ClearableFileInput widget forgets "Clear" selection when form is not valid
Reported by: | bmihelac | Owned by: | Marcelo Galigniana |
---|---|---|---|
Component: | Forms | Version: | 4.1 |
Severity: | Normal | Keywords: | admin, forms, ClearableFileInput |
Cc: | Marcelo Galigniana | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
ClearableFileInput widget forgets "Clear" selection when form is not valid, that causes file would not be deleted once when form is valid again. This can be inconvinient, especially for forms with many fields.
To reproduce:
- Choose admin for any model instance where attachment is not required and has some validation,
- check "Clear" next to the attachment, and change the form, so validation would fail,
- Save form, validation error would occur, attachment and "Clear" would be empty
- make form valid again and Save, attachment woult not be cleared
(I am attaching example screenshots)
https://code.djangoproject.com/attachment/ticket/34488/clearable-file-input-before.png
https://code.djangoproject.com/attachment/ticket/34488/clearable-file-input-validation-error.png
https://code.djangoproject.com/attachment/ticket/34488/clearable-file-input-validation-success.png
Attachments (7)
Change History (22)
comment:1 by , 21 months ago
Description: | modified (diff) |
---|
comment:2 by , 21 months ago
Description: | modified (diff) |
---|
by , 21 months ago
Attachment: | clearable-file-input-before.png added |
---|
by , 21 months ago
Attachment: | clearable-file-input-validation-error.2.png added |
---|
by , 21 months ago
Attachment: | clearable-file-input-validation-error.png added |
---|
validation error occurs (ClearableFileInput has no file and has no Clear checkbox)
by , 21 months ago
Attachment: | clearable-file-input-validation-success.png added |
---|
File is not removed after successful validation and saving
comment:3 by , 21 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 21 months ago
Hello, could you please share your models, forms and admin?
Because everything works fine for me.
follow-up: 7 comment:5 by , 21 months ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Duplicate of #19215 (fixed in c0fc1b5302f5d9d82e2255fb5758321fbac34949, Django 4.2+).
by , 21 months ago
Attachment: | django41-c.webm added |
---|
by , 21 months ago
Attachment: | django42-c.webm added |
---|
comment:6 by , 21 months ago
Hi Basha,
I have created minimum app
https://github.com/bmihelac/django-34488
credentials are admin:test
Please note that app behaves differently in Django 4.1.x and Django 4.2.x (as you can see on screencast below or try yourself). Django 4.2 still forget clear checkbox, but at least checkbox is shown.
https://code.djangoproject.com/attachment/ticket/34488/django41-c.webm
https://code.djangoproject.com/attachment/ticket/34488/django42-c.webm
let me know if anything else is needed
follow-up: 8 comment:7 by , 21 months ago
Replying to Mariusz Felisiak:
Duplicate of #19215 (fixed in c0fc1b5302f5d9d82e2255fb5758321fbac34949, Django 4.2+).
It still forgot Clear choice on validation error in Django 4.2 (this is visible in https://code.djangoproject.com/attachment/ticket/34488/django42-c.webm screencast)
comment:8 by , 21 months ago
Cc: | added |
---|
Replying to bmihelac:
Replying to Mariusz Felisiak:
Duplicate of #19215 (fixed in c0fc1b5302f5d9d82e2255fb5758321fbac34949, Django 4.2+).
It still forgot Clear choice on validation error in Django 4.2 (this is visible in https://code.djangoproject.com/attachment/ticket/34488/django42-c.webm screencast)
"Clear" is always unchecked, I'm not sure if we should change this. Marcelo, what do you think?
by , 21 months ago
Attachment: | ticket_34488_mgaligniana.jpeg added |
---|
When do a submit and validation error occurs, we persist the "invalid" data in the form. I think keep the checkbox checked would be the same behaviour.
comment:9 by , 21 months ago
Resolution: | duplicate |
---|---|
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
When do a submit and validation error occurs, we persist the "invalid" data in the form. I think keep the checkbox checked would be the same behaviour.
Agreed. Would you like to prepare a patch?
comment:10 by , 20 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Sure!
I see Baha Sdtbekov took the owner 4 days ago. I'm going to assign it to me but in case you already been working on it, please let me know!
Thanks!
comment:12 by , 20 months ago
Patch needs improvement: | unset |
---|
comment:13 by , 20 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
initial state