From 421ca931736e29703beefbf5235f25d39aaf0494 Mon Sep 17 00:00:00 2001
From: Tamara Steinwender <tamara.steinwender@tugraz.at>
Date: Mon, 19 Jul 2021 10:54:03 +0200
Subject: [PATCH] Fix select2 focus problem #58

---
 .../check-in-place-select/src/check-in-place-select.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/packages/check-in-place-select/src/check-in-place-select.js b/packages/check-in-place-select/src/check-in-place-select.js
index 992b6148..093a7d1d 100644
--- a/packages/check-in-place-select/src/check-in-place-select.js
+++ b/packages/check-in-place-select/src/check-in-place-select.js
@@ -194,9 +194,17 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) {
                     that.isSearching = false;
                 }
             }
+        }).on("select2:open", function (e) {
+            const selectId = e.target.id;
+
+            that.$(".select2-search__field[aria-controls='select2-" + selectId + "-results']").each(function (
+                key,
+                value,
+            ) {
+                value.focus();
+            });
         }).on("select2:select", function (e) {
             that.$('#check-in-place-select-dropdown').removeClass('select2-bug');
-
             // set custom element attributes
             const identifier = e.params.data.id;
             const maxCapacity = e.params.data.maximumPhysicalAttendeeCapacity;
-- 
GitLab