From 97a1ff507f898e896cf4670d273c1f34b29c72c3 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 24 Nov 2020 12:04:19 +0100
Subject: [PATCH] check-in-place-select: try to work around select2 bug on
 firefox mobile

When selecting select2 shows the "loading.." state for a short time there
which shifts down the result list and makes the selection select the wrong
item.

Work around that by hiding the loading indicator after fetching the data is done
and allow it again once something is selected.
---
 .../check-in-place-select/src/check-in-place-select.js    | 8 ++++++++
 1 file changed, 8 insertions(+)

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 b5b935da..d2a25948 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
@@ -168,6 +168,8 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) {
                     };
                 },
                 processResults: function (data) {
+                    that.$('#check-in-place-select-dropdown').addClass('select2-bug');
+
                     that.lastResult = data;
                     let transformed = that.jsonld.transformMembers(data, checkInPlaceContext);
                     const results = [];
@@ -185,6 +187,8 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) {
                 }
             }
         }).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;
@@ -356,6 +360,10 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) {
                 -webkit-appearance: none;
             }
 
+            /* https://github.com/select2/select2/issues/5457 */
+            .select2-bug .loading-results {
+                display: none !important;
+            }
             `
         ];
     }
-- 
GitLab