Is there an option to close the select list after selection, even if it's a multivalue option field? So select one thing, and if you don't want to select another your clear to go on to the next field (which might be under and so hidden by the current dropdown otherwise), and if not ready, you just have to click in the select box or press the down arrow to get the options back visible again?

Comments

mlncn created an issue. See original summary.

mlncn’s picture

Status: Active » Needs review

There is an option, literally called 'closeAfterSelect', and it's documented at https://github.com/selectize/selectize.js/blob/master/docs/usage.md#general

closeAfterSelect 	If true, the dropdown will be closed after a selection is made. 	boolean 	false

In Drupal code that looks simply like this:

     $form['ages'] = [
        '#type' => 'selectize',
        '#settings' => Selectize::settings([
          'plugins' => ['remove_button'],
          'placeholder' => t('Select one or more ages'),
          'closeAfterSelect' => TRUE,
        ]),
        '#title' => $this->t('Ages'),
        '#options' => $ages_options,
        '#multiple' => TRUE,
        '#default_value' => $this->getRequest()->query->get('ages'),
        '#empty_value' => '',
      ];

We probably don't want to document every Selectize option, but we should at least add a page for where to look for them and how to add them like this in the Drupal context.

I think a maintainer has to add a stub documentation page before others can edit.

mlncn’s picture

Title: Close after select » Document close after select

Selectized dropdowns should also close if they are clicked or pressed without selecting anything, and that is an open bug with Selectize.js, with some brittle workarounds given in comments:

https://github.com/selectize/selectize.js/issues/1261
https://github.com/selectize/selectize.js/issues/1377