diff --git a/.eslintrc b/.eslintrc
index b1cd7fd3..176b1fe9 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -16,7 +16,8 @@
"Modernizr": true,
"Popper": true,
"Sortable": true,
- "CKEDITOR": true
+ "CKEDITOR": true,
+ "once": true
},
"rules": {
"array-bracket-spacing": ["error", "never"],
diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml
index b35461ed..5d96f96e 100644
--- a/.github/workflows/reviewdog.yml
+++ b/.github/workflows/reviewdog.yml
@@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v1
- name: phpcs
- uses: chrfritsch/action-drupal-coder@v1
+ uses: thunder/action-drupal-coder@v1
with:
github_token: ${{ secrets.github_token }}
level: error
diff --git a/.github/workflows/testing.yml b/.github/workflows/test.yml
similarity index 82%
rename from .github/workflows/testing.yml
rename to .github/workflows/test.yml
index c45e0177..1e490ce3 100644
--- a/.github/workflows/testing.yml
+++ b/.github/workflows/test.yml
@@ -17,6 +17,7 @@ env:
DRUPAL_TESTING_DATABASE_ENGINE: mysql
DRUPAL_TESTING_HTTP_PORT: 8888
DRUPAL_TESTING_PARALLEL_TESTING: true
+ DRUPAL_TESTING_SELENIUM_CHROME_VERSION: "105.0"
jobs:
build:
@@ -33,8 +34,8 @@ jobs:
strategy:
matrix:
- DRUPAL_TESTING_DRUPAL_VERSION: ['~9.2.0']
- PHP_VERSION: [ '8.0' ]
+ DRUPAL_TESTING_DRUPAL_VERSION: ['~10.0.0']
+ PHP_VERSION: [ '8.1' ]
steps:
- uses: actions/checkout@v2
@@ -47,7 +48,7 @@ jobs:
with:
coverage: none
php-version: ${{ matrix.PHP_VERSION }}
- extensions: Imagick, gd, pdo_mysql
+ extensions: :sodium, Imagick, gd, PDO, mysql, pdo_mysql, mbstring, xmlwriter, pdo, date, dom, filter, hash, json, pcre, session, SimpleXML, SPL, tokenizer, xml, curl
- name: Cache composer dependencies
uses: actions/cache@v1
@@ -65,7 +66,9 @@ jobs:
restore-keys: ${{ runner.os }}-npm-cache
- name: Get build environment
- run: composer global require thunder/drupal-testing
+ run: |
+ composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true --no-plugins
+ composer global require thunder/drupal-testing
- name: Prepare the build
run: test-drupal-project prepare_build
diff --git a/composer.json b/composer.json
index f8e39ae8..ebc2ec2b 100644
--- a/composer.json
+++ b/composer.json
@@ -10,9 +10,15 @@
}
],
"require-dev": {
- "drupal/facets": "^2.0",
- "drupal/search_api": "^1.17",
- "drupal/form_options_attributes": "^1.2",
- "drupal/better_exposed_filters": "^5.0"
+ "drupal/facets": "2.0.x-dev",
+ "drupal/search_api": "^1.28",
+ "drupal/form_options_attributes": "^2.0"
+ },
+ "extra": {
+ "patches": {
+ "drupal/facets": {
+ "InvalidArgumentException: Expected a scalar value as a 2nd argument to \"Symfony\\Component\\HttpFoundation\\InputBag::get()\", \"array\" given": "https://www.drupal.org/files/issues/2022-11-17/3310536-2.x-6.patch"
+ }
+ }
}
}
diff --git a/js/select2.js b/js/select2.js
index 8aaec4c6..48dfbf46 100644
--- a/js/select2.js
+++ b/js/select2.js
@@ -2,12 +2,12 @@
* @file
* Select2 integration.
*/
-(function ($, drupalSettings, Sortable) {
+(function ($, drupalSettings, Sortable, once) {
'use strict';
Drupal.behaviors.select2 = {
attach: function (context) {
- $('.select2-widget', context).once('select2-init').each(function () {
+ $(once('select2-init', '.select2-widget', context)).each(function () {
var config = $(this).data('select2-config');
config.createTag = function (params) {
var term = $.trim(params.term);
@@ -77,4 +77,4 @@
}
};
-})(jQuery, drupalSettings, Sortable);
+})(jQuery, drupalSettings, Sortable, once);
diff --git a/modules/select2_facets/js/select2-widget.js b/modules/select2_facets/js/select2-widget.js
index 20e4e06a..dd5e9e2b 100644
--- a/modules/select2_facets/js/select2-widget.js
+++ b/modules/select2_facets/js/select2-widget.js
@@ -3,7 +3,7 @@
* Init select2 widget.
*/
-(function ($, Drupal) {
+(function ($, Drupal, once) {
'use strict';
@@ -13,8 +13,7 @@
* Add event handler to all select2 widgets.
*/
Drupal.facets.initSelect2 = function () {
- $('.js-facets-select2.js-facets-widget')
- .once('js-facets-select2-widget-on-selection-change')
+ $(once('js-facets-select2-widget-on-selection-change', '.js-facets-select2.js-facets-widget'))
.each(function () {
var $select2_widget = $(this);
@@ -37,4 +36,4 @@
}
};
-})(jQuery, Drupal);
+})(jQuery, Drupal, once);
diff --git a/modules/select2_facets/select2_facets.info.yml b/modules/select2_facets/select2_facets.info.yml
index f2b36227..ce2f3373 100644
--- a/modules/select2_facets/select2_facets.info.yml
+++ b/modules/select2_facets/select2_facets.info.yml
@@ -2,7 +2,7 @@ name: Select2 Facets
type: module
description: Provides a Select2 Facet widget.
package: Search
-core_version_requirement: ^9
+core_version_requirement: ^9 || ^10
dependencies:
- facets:facets (>=8.x-2.0)
- select2:select2
diff --git a/modules/select2_facets/tests/src/FunctionalJavascript/FacetsTest.php b/modules/select2_facets/tests/src/FunctionalJavascript/FacetsTest.php
index c682524b..f395f6fd 100644
--- a/modules/select2_facets/tests/src/FunctionalJavascript/FacetsTest.php
+++ b/modules/select2_facets/tests/src/FunctionalJavascript/FacetsTest.php
@@ -69,7 +69,7 @@ public function testBasicFunctionality(array $config, array $expected_settings):
$settings = $this->getSession()->getPage()->findField('Referenced[]')->getAttribute('data-select2-config');
foreach ($expected_settings as $key => $value) {
- if ($key == 'ajax') {
+ if ($key === 'ajax') {
$this->assertArrayHasKey($key, Json::decode($settings));
}
else {
@@ -85,14 +85,16 @@ public function testBasicFunctionality(array $config, array $expected_settings):
$this->assertNotEmpty($assert_session->waitForElement('xpath', '//li[@class="select2-results__option" and text()="Reference 2"]'));
$page->find('xpath', '//li[@class="select2-results__option" and text()="Reference 2"]')->click();
- $assert_session->addressEquals('test-entity-view?f%5B0%5D=referenced%3A2');
+ $current_url = $this->getSession()->getCurrentUrl();
+ $this->assertStringContainsString('f%5B0%5D=referenced%3A2', $current_url);
$this->click('.form-item-referenced .select2-selection.select2-selection--multiple');
$page->find('css', '.select2-search__field')->setValue('Reference');
$this->assertNotEmpty($assert_session->waitForElement('xpath', '//li[@class="select2-results__option" and text()="Reference 1"]'));
$page->find('xpath', '//li[@class="select2-results__option" and text()="Reference 1"]')->click();
- $assert_session->addressEquals('test-entity-view?f%5B0%5D=referenced%3A2&f%5B1%5D=referenced%3A1');
+ $current_url = $this->getSession()->getCurrentUrl();
+ $this->assertStringContainsString('f%5B0%5D=referenced%3A1&f%5B1%5D=referenced%3A2', $current_url);
}
/**
diff --git a/modules/select2_publish/select2_publish.info.yml b/modules/select2_publish/select2_publish.info.yml
index a3c52a77..46fdc481 100644
--- a/modules/select2_publish/select2_publish.info.yml
+++ b/modules/select2_publish/select2_publish.info.yml
@@ -2,7 +2,7 @@ name: Select2 Publish
type: module
description: Indicates the status of referenced entities.
package: User interface
-core_version_requirement: ^8.8 || ^9
+core_version_requirement: ^9 || ^10
dependencies:
- select2:select2
- form_options_attributes:form_options_attributes
diff --git a/select2.info.yml b/select2.info.yml
index c3e03eef..ee4bb6ba 100644
--- a/select2.info.yml
+++ b/select2.info.yml
@@ -2,4 +2,4 @@ name: Select2
type: module
description: Makes entity reference fields more user-friendly using Select2.
package: User interface
-core_version_requirement: ^9
+core_version_requirement: ^9 || ^10
diff --git a/select2.libraries.yml b/select2.libraries.yml
index 30f45510..36a0579a 100644
--- a/select2.libraries.yml
+++ b/select2.libraries.yml
@@ -17,5 +17,6 @@ select2.min:
component:
/libraries/select2/dist/css/select2.min.css: {}
dependencies:
- - core/jquery.once
- core/drupal
+ - core/jquery
+ - core/once
diff --git a/select2.module b/select2.module
index 6f8730d7..b2975e6e 100644
--- a/select2.module
+++ b/select2.module
@@ -10,14 +10,7 @@
*/
function select2_library_info_alter(array &$libraries, string $extension): void {
if ($extension === 'select2') {
- $libraries_path = 'libraries/select2';
- if (\Drupal::hasService('library.libraries_directory_file_finder')) {
- $libraries_path = \Drupal::service('library.libraries_directory_file_finder')->find('select2');
- }
- elseif (function_exists('libraries_get_path')) {
- $libraries_path = libraries_get_path('select2');
- }
-
+ $libraries_path = \Drupal::service('library.libraries_directory_file_finder')->find('select2');
$libraries['select2.min']['js'] = ['/' . $libraries_path . '/dist/js/select2.min.js' => ['minified' => TRUE]];
$libraries['select2.min']['css']['component'] = ['/' . $libraries_path . '/dist/css/select2.min.css' => []];
foreach (\Drupal::languageManager()->getLanguages() as $language) {
diff --git a/src/Controller/EntityAutocompleteController.php b/src/Controller/EntityAutocompleteController.php
index 6dc172d4..622434bd 100644
--- a/src/Controller/EntityAutocompleteController.php
+++ b/src/Controller/EntityAutocompleteController.php
@@ -86,7 +86,7 @@ public function handleAutocomplete(Request $request, string $target_type, string
// key/value store.
throw new AccessDeniedHttpException();
}
- $matches['results'] = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, mb_strtolower($input), $request->query->get('selected', []));
+ $matches['results'] = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, mb_strtolower($input), $request->query->has('selected') ? $request->query->all('selected') : []);
}
return new JsonResponse($matches);
diff --git a/src/Element/Select2.php b/src/Element/Select2.php
index 8fb2af81..27b3bf55 100644
--- a/src/Element/Select2.php
+++ b/src/Element/Select2.php
@@ -38,6 +38,7 @@
* '3' => $this->t('Three'),
* ],
* ];
+ * @endcode
*
* If you want to prevent the rendering of all options and fetch the options via
* ajax instead, you can use the '#autocomplete' property. It's also needed to
@@ -60,6 +61,7 @@
* 'target_bundles' => ['article', 'page'],
* ],
* ];
+ * @endcode
*
* If you want to allow an input of an entity label that does not exist yet but
* can be created "on the fly" on form submission, the '#autocreate' property
@@ -78,6 +80,7 @@
* 'uid' => ,
* ],
* ];
+ * @endcode
*
* The render element sets a bunch of default values to configure the select2
* element. Nevertheless all select2 config values can be overwritten with the
@@ -89,6 +92,7 @@
* 'allowClear' => TRUE,
* ],
* ];
+ * @endcode
*
* @see https://select2.org/configuration/options-api
*
diff --git a/tests/src/FunctionalJavascript/FieldWidget/Select2EntityReferenceWidgetTest.php b/tests/src/FunctionalJavascript/FieldWidget/Select2EntityReferenceWidgetTest.php
index 53281e6d..2b55d22d 100644
--- a/tests/src/FunctionalJavascript/FieldWidget/Select2EntityReferenceWidgetTest.php
+++ b/tests/src/FunctionalJavascript/FieldWidget/Select2EntityReferenceWidgetTest.php
@@ -391,7 +391,7 @@ public function testAutocompleteOrdering(): void {
$settings = Json::decode($this->getSession()->getPage()->findField('select2')->getAttribute('data-select2-config'));
$url = Url::fromUserInput($settings['ajax']['url']);
- $url->setAbsolute(TRUE);
+ $url->setAbsolute();
$url->setRouteParameter('q', 'f');
$response = \Drupal::httpClient()->get($url->toString());
diff --git a/tests/src/FunctionalJavascript/Form/ElementTest.php b/tests/src/FunctionalJavascript/Form/ElementTest.php
index e4588a53..a26a4a56 100644
--- a/tests/src/FunctionalJavascript/Form/ElementTest.php
+++ b/tests/src/FunctionalJavascript/Form/ElementTest.php
@@ -62,18 +62,18 @@ public function testAjaxCallbacksInBetween(): void {
}
/**
- * Test loading of seven theme style.
+ * Test loading of claro theme style.
*/
- public function testSevenTheme(): void {
- $this->container->get('theme_installer')->install(['seven']);
+ public function testClaroTheme(): void {
+ $this->container->get('theme_installer')->install(['claro']);
$this->config('system.theme')
- ->set('default', 'seven')
- ->set('admin', 'seven')
+ ->set('default', 'claro')
+ ->set('admin', 'claro')
->save();
$this->drupalGet('/select2-optgroup-form');
- $this->assertSession()->elementExists('css', '.select2-container--seven');
+ $this->assertSession()->elementExists('css', '.select2-container--claro');
$select2_js = $this->xpath("//script[contains(@src, 'select2/js/select2.js')]");
$this->assertEquals(1, count($select2_js));