yourlabs/django-autocomplete-light

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

Alireza-Farahani opened this issue · 3 comments

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.

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

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?

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 - apalfrey/select2-bootstrap-5-theme#70 (comment)