You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiselect does not clear search textarea on select when closeOnSelect is false #6387
When closeOnSelect is false, a multiselect does not clear the text entered in the search textarea when an option is selected.
How to reproduce
<selectclass="select2 form-control select2-multiple" data-toggle="select2" multiple="multiple"><optgrouplabel="Alaskan/Hawaiian Time Zone"><optionvalue="AK">Alaska</option><optionvalue="HI">Hawaii</option></optgroup><optgrouplabel="Pacific Time Zone"><optionvalue="CA">California</option><optionvalue="WA">Washington</option></optgroup><optgrouplabel="Mountain Time Zone"><optionvalue="AZ">Arizona</option><optionvalue="CO">Colorado</option><optionvalue="ID">Idaho</option><optionvalue="WY">Wyoming</option></optgroup><optgrouplabel="Central Time Zone"><optionvalue="AL">Alabama</option><optionvalue="AR">Arkansas</option><optionvalue="IL">Illinois</option><optionvalue="WI">Wisconsin</option></optgroup><optgrouplabel="Eastern Time Zone"><optionvalue="CT">Connecticut</option><optionvalue="DE">Delaware</option><optionvalue="FL">Florida</option><optionvalue="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.
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.
Activity
sridharkalaibala commentedon Sep 14, 2026
Confirmed against a fresh build of current
develop(06e2dcfd836c2c3c5ca970550c5ecc1d6919bdfd), using jQuery 3.7.1 and Chromium:After typing
Alaand clicking Alaska, Alaska is selected, the dropdown stays open, the input still containsAla, and the results remain Alaska/Alabama. Inselection/search.js, the input is cleared in theclosehandler; 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.