When we use the select2 element as a facet widget then we get the following error.

JS error - Uncaught Sortable: `el` must be an HTMLElement, not [object Undefined]

This was caused by the following code part.

var $list = $select.next('.select2-container').find('ul.select2-selection__rendered');

Where the list length is equal to 0.

I propose that we add a extra check to see if the list exists.

Issue fork select2-3379063

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

p-neyens created an issue. See original summary.

p-neyens’s picture

StatusFileSize
new1.19 KB
p-neyens’s picture

Status: Active » Needs review
shalini_jha’s picture

I have also encountered the same issue in the console. After applying patch #2, it fixes the issue.

hmdnawaz’s picture

Version: 8.x-1.15 » 2.x-dev

miltonqp’s picture

I tested the changes from https://git.drupalcode.org/project/select2/-/merge_requests/47, and they work fine in version 2

waropd’s picture

StatusFileSize
new1.27 KB

Adding patch of the current MR