Skip to content

fix: improper width for autocomplete fields in tabular inline #1211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tudoramariei opened this issue Apr 10, 2025 · 3 comments
Closed

fix: improper width for autocomplete fields in tabular inline #1211

tudoramariei opened this issue Apr 10, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@tudoramariei
Copy link

What version of Unfold are you using?

0.54.0

What version of Django are you using?

5.1.8

What browser are you using?

Chrome 135.0.7049.42

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

Yes, and located that the issue is on this line and caused by this commit

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

Yes

Did you checked documentation?

No

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

No, because I don't think there's a TabularInline where I can create a new many-to-many object

Repository with reproduced bug

This is the inline where we have the issue
https://github.com/code4romania/redirectioneaza/blob/7bac0a30c866f612c631a0ee673fa91193cf6dcf/backend/partners/admin.py#L44

Describe your issue

I have two models, in a many-to-many relationship, connected by a through model. In the admin of the first model I have a tab with tabular inlines to create connections to the second model with an autocomplete field.
After the latest changes, all the fields are of the same (button) size, including the search field. This makes searching really difficult.

Workaround: Select an item from the list (if it's selectable) and the section resizes based on the content so that you can actually search.

Reproducing this can be done with the following code (using FirstModel and SecondModel but you can see the original code in the previous section of this issue):

class SecondModelInline(TabularInline):
    model = FirstModel.second_models.through
    extra = 1
    tab = True

    autocomplete_fields = ("second_model",)

@admin.register(FirstModel)
class FirstModelAdmin(ModelAdmin):
    ...
    inlines = (SecondModelInline,)

How this section looks in 0.53
Image

How this section looks in 0.54
Image

How this section looks in 0.54 with w-full added to the div's classes
Image

@lukasvinclav lukasvinclav added the bug Something isn't working label Apr 10, 2025
@lukasvinclav lukasvinclav changed the title Creating through tabular inlines is buggy starting with 0.54.0 fix: improper width for autocomplete fields in tabular inline Apr 10, 2025
@afsangujarati93
Copy link

afsangujarati93 commented Apr 15, 2025

Adding to this, I also see an issue when the text in the autocomplete is very long.

I am on version 0.55.2

Image

Update:
Looks like w-full fixes that too.

@lukasvinclav lukasvinclav marked this as a duplicate of #1232 Apr 16, 2025
@devxoul
Copy link

devxoul commented Apr 23, 2025

I added custom css as a workaround.

unfold-autocomplete.css

.select2 {
  min-width: 190px;
}

settings.py

UNFOLD = {
    # ...
    "STYLES": [
        lambda request: static("admin/unfold-autocomplete.css"),
    ],
    # ...
}

@lukasvinclav
Copy link
Contributor

@devxoul I think, I already fixed the issue in another branch which I'm working on right now

#1234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants