From 073365602fa549e66c3dd1f24df4c274439410ab Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Mon, 19 Sep 2022 15:44:24 +0000
Subject: [PATCH] also enable select2 for select with optgroup, fixes #1592

Closes #1592

Merge request studip/studip!1022
---
 resources/assets/javascripts/bootstrap/forms.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js
index 60ae9c3244e..3bf5026ef42 100644
--- a/resources/assets/javascripts/bootstrap/forms.js
+++ b/resources/assets/javascripts/bootstrap/forms.js
@@ -361,7 +361,7 @@ STUDIP.ready(function () {
     //
     // Thus, we need to handle the visible elements first and apply
     // select2 directly.
-    $('select.nested-select:not(:has(optgroup)):visible').each(function() {
+    $('select.nested-select:visible').each(function() {
         createSelect2(this);
     });
 
@@ -370,7 +370,7 @@ STUDIP.ready(function () {
     // visible element from the requested select element and observe style,
     // class and attribute changes in order to detect when the select
     // element itself will become visible. Pretty straight forward, huh?
-    $('select.nested-select:not(:has(optgroup)):hidden:not(.select2-awaiting)').each(function() {
+    $('select.nested-select:hidden:not(.select2-awaiting)').each(function() {
         var observer = new window.MutationObserver(onDomChange);
         observer.observe($(this).closest(':visible')[0], {
             attributeOldValue: true,
@@ -413,7 +413,7 @@ $(document)
         $(this).toggleClass('has-no-value', this.value === '');
     })
     .on('dialog-close', function(event, data) {
-        $('select.nested-select:not(:has(optgroup))', data.dialog).each(function() {
+        $('select.nested-select', data.dialog).each(function() {
             if (!$(this).data('select2')) {
                 return;
             }
-- 
GitLab