Opened 3 years ago

Closed 2 years ago

#33024 closed Bug (fixed)

filter_horizontal doesn't use full height when in collapsed fieldset

Reported by: Peter Tillema Owned by: Shubh Parmar
Component: contrib.admin Version: 3.2
Severity: Normal Keywords: filter_horizontal, fieldsets, admin
Cc: Shubh Parmar 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

Say you have a field field in model X, which is a ManyToMany field. You can use filter_horizontal in the ModelAdmin to display the available and selected options. However, if you use filter_horizontal in combination with a fieldset which is collapsed by default, it won't take the full height.

Example:

@admin.register(X)
class XAdmin(admin.ModelAdmin):
    list_display = ('a', 'b', 'c', 'field')
    filter_horizontal = ('field',)
    
    fieldsets = (
        (None, {
            'fields': ('a', 'b', 'c')
        }),
        ('Other', {
            'classes': ('collapse',),
            'fields': ('field',)
        })
    )

which gets rendered as https://i.imgur.com/jZpUHYN.png

Attachments (1)

ticket_33024.diff (3.3 KB ) - added by Shubh Parmar 2 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Peter Tillema, 3 years ago

Type: UncategorizedBug

comment:2 by Carlton Gibson, 3 years ago

Triage Stage: UnreviewedAccepted

Hi Peter — OK, thanks. If you'd like to look at an adjustment here, that would be great!

comment:3 by Shubh Parmar, 2 years ago

Cc: Shubh Parmar added
Owner: changed from nobody to Shubh Parmar
Status: newassigned

comment:5 by Mariusz Felisiak, 2 years ago

Has patch: set
Patch needs improvement: set

comment:6 by Mariusz Felisiak, 2 years ago

Needs tests: set

by Shubh Parmar, 2 years ago

Attachment: ticket_33024.diff added

comment:7 by Shubh Parmar, 2 years ago

I think we can solve this issue with just CSS. In that case, we don't need to write javascript for calculating the height of select boxes. I have uploaded a git diff file. Let me know whether this is okay or not.

comment:8 by Mariusz Felisiak, 2 years ago

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 51c24d87:

Fixed #33024 -- Fixed height of admin selector boxes in collapsed fieldset.

Thanks Tom Carrick for the review.

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