platanus / activeadmin_addons

Extends ActiveAdmin to enable a set of great optional UX improving add-ons
MIT License
763 stars 288 forks source link

Replace Select2 with SlimSelect #448

Closed gmq closed 1 year ago

gmq commented 1 year ago

Context

Select2 is difficult to configure and use with newer bundlers based on esbuild. Rather than attempting to make it work, this pull request replaces the library with a more up-to-date alternative while attempting to maintain similar usage.

Breaking Changes

This implementation replaces ActiveAdmin's jQuery events with a MutationObserver. Instead of listening to has_many_* events, the MutationObserver watches for new elements and initializes slim-select where necessary. It covers most typical use cases, but there may be scenarios that I have not taken into account.

Changes

I added our standard ESLint configuration to accommodate the use of ES6 syntax in newer files. This may result in a lot of red lines in older files, but since they are not touched often, it shouldn't be a major issue.

Possible Issues

It may be necessary to fork slim-select to fix outstanding issues since the author of the library works sporadically on it. This is alleviated in part by the fact that we don't really need any new features. Once we get it working with no issues, there won't be a need for continued development, and we can contribute the fixes to upstream.