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.

Command icon 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

eadams432 created an issue. See original summary.

adrian_s_m’s picture

Status: Active » Needs review

Set as needs review first

adrian_s_m’s picture

Status: Needs review » Reviewed & tested by the community

I have pulled this locally and reviewed the changes and works as expected. Thank you for adding the test @eadams432!

dave reid’s picture

Ooh thanks for the merge request, I'm reviewing this at DrupalCon Chicago this week!

dave reid’s picture

Version: 8.x-1.4 » 8.x-1.x-dev

@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.

dave reid’s picture

I 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?

adrian_s_m’s picture

@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!

dave reid’s picture

Okay, I will get this merged and tagged Monday.

adrian_s_m’s picture

@dave reid I'll give this a shot, it will be a good learning opportunity.

adrian_s_m’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.