yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.79k stars 467 forks source link

Incompatibility with select2-bootstrap-5-theme. Clear button not appearing. #1301

Closed Alireza-Farahani closed 1 year ago

Alireza-Farahani commented 2 years ago

When using select2-bootstrap-5-theme package for theming, clear button doesn't appear. This is clearly a compatibility issue between these two package since DAL in isolation works fine and same for select2-bootstrap-5. I don't know if it's DAL issue or select2-bootstrap-5 issue so I created a issue there too.

Steps to reproduce:

  1. Setup DAL in a new Django project.
  2. Add select2-bootstrap-5 css.
  3. Set "data-bootstrap-5" and "data-allow-clear" in widget's data attributes.
    autocomplete.ModelSelect2(
    url='<View url>',
    attrs={
        'data-theme': 'bootstrap-5',
        'data-allow-clear': True
    },
    )

    image

I created a sample repository that shows the issue.

shapiromatron commented 1 year ago

Ok to close @Alireza-Farahani ? Looks like the issue was related to script order - in the cross-post, it looks like this was resolved. https://github.com/apalfrey/select2-bootstrap-5-theme/issues/70

Alireza-Farahani commented 1 year ago

Yep. I'm going to close this. However as a side question, @shapiromatron what do you suggest as the best solution to scripts order? Subclassing DAL classes, putting select2-bootstrap-5 css files at the end of <body> of my base template or another way I'm not aware of?

shapiromatron commented 1 year ago

Hey @Alireza-Farahani; I'd just change the import order in html, and not get too fancy with subclassing DAL classes. In fact, the response from @apalfrey on the other issue seemed entirely correct - https://github.com/apalfrey/select2-bootstrap-5-theme/issues/70#issuecomment-1222057988