Commit af207ae8 authored by Joshua Sedler's avatar Joshua Sedler 🤸🏼 Committed by Julian Pustkuchen
Browse files

Issue #3317961 by Grevil, Anybody: Choices won't work if "css-selector"...

Issue #3317961 by Grevil, Anybody: Choices won't work if "css-selector" textarea is empty or multiple selectors are entered
parent 25987e2d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
use_cdn: false
dropdown_type: 1
css_selector: 'select[multiple=multiple]'
css_selector: 'select[multiple]'
include: 2
configuration_options: ''
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
     * Drupal attach behavior.
     */
    attach: function (context, settings) {
      var selector = settings.choices.cssSelector || [];
      var selector = settings.choices.cssSelector;
      if (settings.choices.hasFacetsWidget) {
        selector.push('.js-facets-choices');
      }
+2 −1
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@ class ChoicesCallbacks implements TrustedCallbackInterface {
      $cssSelector = \Drupal::config('choices.settings')->get('css_selector');
      $configurationOptions = \Drupal::config('choices.settings')->get('configuration_options');
      $attached['library'][] = 'choices/choices';
      $attached['drupalSettings']['choices']['cssSelector'] = explode("\n", $cssSelector);
      // Replace multiple spaces and newlines with a comma and single space:
      $attached['drupalSettings']['choices']['cssSelector'] = trim(preg_replace('/\s\s+/', ', ', $cssSelector));
      $attached['drupalSettings']['choices']['configurationOptions'] = $configurationOptions;
    }
    return $element;
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ class ConfigForm extends ConfigFormBase {
    $form['css_selector'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Apply Choices.js to the following elements'),
      '#required' => TRUE,
      '#description' => $this->t('List of CSS selectors, one per line, to apply Choices.js to, such as <code>select#edit-operation, select#edit-type</code> or <code>.choices-select</code>. Defaults to <code>select[multiple=multiple]</code> to apply Choices.js to all multiple <code>&lt;select&gt;</code> elements.'),
      '#default_value' => $config->get('css_selector'),
    ];