Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32623 closed Bug (worksforme)

Collapsible fieldsets inside inlines do not work

Reported by: Matthias Kestenholz Owned by: nobody
Component: contrib.admin Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When using a stacked inline with fieldsets = [(..., {"classes": ["collapse"]})] the expected behavior would be that the Show/Hide functionality works not only in existing inlines but also in inlines which have been dynamically added via the "add another" button.

This isn't the case currently. The reason for this is (probably) that the event listener is only attached to <fieldset class="module"> elements existing at page load.

Replacing the code here https://github.com/django/django/blob/45a58c31e64dbfdecab1178b1d00a3803a90ea2d/django/contrib/admin/static/admin/js/collapse.js#L39-L41 with document.body.addEventListener("click", toggleFunc) _may_ be a sufficient fix but I haven't tested this. This should be relatively easy (famous last words) and I hope it's a good start for someone to start submitting patches to Django :-)

Change History (2)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: worksforme
Status: newclosed

Thanks for the report, however it works for me (see also #30459 and a test added in e286987a27271c8ee7eb6e4d4332b563c4e6094b).

comment:2 by Matthias Kestenholz, 3 years ago

Oh no, you're right. Sorry for not checking two or three times before submitting this report!

Note: See TracTickets for help on using tickets.
Back to Top