From: Coleman Watts Date: Fri, 14 Jan 2022 14:40:11 +0000 (-0500) Subject: Select2 - Fix auto-expanding collapsible optgroups for multi-selects X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=390bfe803715d395d38683c529a5846e269ff540;p=civicrm-core.git Select2 - Fix auto-expanding collapsible optgroups for multi-selects Fixes dev/core#3032 --- diff --git a/js/Common.js b/js/Common.js index e24b9dadf7..fb9d0c3d8a 100644 --- a/js/Common.js +++ b/js/Common.js @@ -483,8 +483,8 @@ if (!CRM.vars) CRM.vars = {}; $('.crm-select2-row-description', '#select2-drop').each(function() { $(this).closest('.select2-result-label').attr('title', $(this).text()); }); - // Collapsible optgroups should be expanded when searching - if ($('#select2-drop.collapsible-optgroups-enabled .select2-search input.select2-input').val()) { + // Collapsible optgroups should be expanded when searching (searching happens within select2-drop for single selects, but within the element for multiselects; this handles both) + if ($('#select2-drop.collapsible-optgroups-enabled .select2-search input.select2-input, .select2-dropdown-open.collapsible-optgroups .select2-search-field input.select2-input').val()) { $('#select2-drop.collapsible-optgroups-enabled li.select2-result-with-children') .addClass('optgroup-expanded'); }