Skip to content

Multiselect does not clear search textarea on select when closeOnSelect is false #6387

Open

Description

@threatspike-eddie

When closeOnSelect is false, a multiselect does not clear the text entered in the search textarea when an option is selected.

How to reproduce

<select class="select2 form-control select2-multiple" data-toggle="select2" multiple="multiple">
  <optgroup label="Alaskan/Hawaiian Time Zone">
    <option value="AK">Alaska</option>
    <option value="HI">Hawaii</option>
  </optgroup>
  <optgroup label="Pacific Time Zone">
    <option value="CA">California</option>
    <option value="WA">Washington</option>
  </optgroup>
  <optgroup label="Mountain Time Zone">
    <option value="AZ">Arizona</option>
    <option value="CO">Colorado</option>
    <option value="ID">Idaho</option>
    <option value="WY">Wyoming</option>
  </optgroup>
  <optgroup label="Central Time Zone">
    <option value="AL">Alabama</option>
    <option value="AR">Arkansas</option>
    <option value="IL">Illinois</option>
    <option value="WI">Wisconsin</option>
  </optgroup>
  <optgroup label="Eastern Time Zone">
    <option value="CT">Connecticut</option>
    <option value="DE">Delaware</option>
    <option value="FL">Florida</option>
    <option value="WV">West Virginia</option>
  </optgroup>
</select>
$('.select2').select2({ closeOnSelect: false });

Typing Ala and clicking Alaska in the dropdown does not clear the text Ala from the search textarea.

Expected behaviour

The search textarea should clear once an option is selected.

Activity

  1. sridharkalaibala commented on Sep 14, 2026

    @sridharkalaibala

    Confirmed against a fresh build of current develop (06e2dcfd836c2c3c5ca970550c5ecc1d6919bdfd), using jQuery 3.7.1 and Chromium:

    <select multiple>
      <option>Alaska</option>
      <option>Alabama</option>
      <option>California</option>
    </select>
    $('select').select2({ closeOnSelect: false });

    After typing Ala and clicking Alaska, Alaska is selected, the dropdown stays open, the input still contains Ala, and the results remain Alaska/Alabama. In selection/search.js, the input is cleared in the close handler; this interaction doesn't close the dropdown.

    Related earlier proposals are #5583 and #6022 (both closed). There is a behavior choice worth making explicit before reviving a fix: should selecting also reset the query so California and other nonmatching options return, or preserve the filtered results for selecting several matches? Clearing only the visible input would leave filtered results without a visible search term. I can reproduce the current issue, but have not submitted that partial change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions