unfoldadmin/django-unfold

Double select block on Inline with autocomplete fields

Closed this issue · 5 comments

What version of Unfold are you using?

0.39.0

What version of Django are you using?

5.1.1

What browser are you using?

Google Chrome Version 129.0.6668.90 (Official Build) (arm64)

Did you checked changelog/commit history, if the bug is not already fixed?

Yes, this bug appeared since 0.33.0

Did you searched other issues, if the bug is not already fixed?

Yes

Did you checked documentation?

Yes

Are you able to replicate the bug in the demo site?

There is no page to reproduce.

Repository with reproduced bug

Create minimal repository where it is possible to reproduce an error.

Describe your issue

When using StackedInline and TabularInline with autocomplete mode, the select block is duplicated. However, if you remove the line and create it again, there will be no duplication.

Code:

# ...

class MatchTranslationInline(unfold_admin.StackedInline):
    model = models.MatchTranslation
    extra = 0
    fields = ("language", "name")
    autocomplete_fields = ("language",)
    can_delete = True

class MatchTeamInline(unfold_admin.TabularInline):
    model = models.MatchTeam
    extra = 0
    autocomplete_fields = ("team",)
    ordering = ("-home_team",)
    can_delete = True

# ...

@admin.register(models.Match)
class MatchAdmin(unfold_admin.ModelAdmin, BackgroundTaskPermissionMixin):
    # ...
    inlines = [MatchTeamInline, MatchTranslationInline]

image

image

image

After remove and add:

image

same problem

I did some research. It was broken by these changes. I have lack of experience in CSS but I guess the problem is in the CSS file.

I've already tried to replace src/unfold/templates/admin/edit_inline/stacked.html and src/unfold/templates/admin/edit_inline/tabular.html from version 0.32.0 to 0.40.0 but nothing has changed

On version0.32.0: everything is okay
image

Thanks for report. PR #800 is fixing this issue.