Problem/Motivation
When using this module with Drupal 11, the Select2 initialization fails because the version of select2 loaded by default relies on deprecated jQuery functions that have been removed in jQuery 4.
Users will see an error in the console: Uncaught TypeError: $.isArray is not a function
This renders the Select2 widget non-functional.
Steps to reproduce
1. Install Drupal 11.
2. Install and enable `select2_all`.
3. Add a field field to any content type, allow more than one selection.
4. Visit the node edit form.
5. Observe that the select element is not enhanced and the browser console displays Uncaught TypeError: $.isArray is not a function
Proposed resolution
Update the default library definitions in `select2_all.libraries.yml` to use select2@4.1.0-rc.0.
Additionally, this update introduces a slight regression in the styling of multi-select elements (margin issues). A CSS fix is proposed for css/select2.css to restore the correct margin behavior for the select2-selection__rendered element.
Remaining tasks
Create Merge Request with library update
User interface changes
Small styling changes stemming from the updates to select2.
API changes
None.
Data model changes
None.
Issue fork select2_all-3580578
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
adrian_s_m commentedSet as needs review first
Comment #4
adrian_s_m commentedI have pulled this locally and reviewed the changes and works as expected. Thank you for adding the test @eadams432!
Comment #5
dave reidOoh thanks for the merge request, I'm reviewing this at DrupalCon Chicago this week!
Comment #6
dave reid@Adrian_S_M That would be wonderful if you could re-check. I don't know if you have legacy CKEditor4 around to test as well, since I don't currently.
Comment #7
dave reidI updated the code to work with any select fields that might be in the vertical tabs sidebar of content forms, most importantly, the Menu UI parent select field. I've been testing this and it seems to work well?
Comment #8
adrian_s_m commented@dave reid I was able to test this in profile and D11 and works as expected. unfortunately i don't have a good way of testing for CKEditor4, but based on your changes I don't have any concerns. Thank you for improving this!
Comment #9
dave reidOkay, I will get this merged and tagged Monday.
Comment #10
adrian_s_m commented@dave reid I'll give this a shot, it will be a good learning opportunity.
Comment #12
adrian_s_m commentedThis was fixed as part of https://git.drupalcode.org/project/select2_all/tree/8.x-1.5