From 9b7321ecdaee9dddf3319f5a47afc825138b45dd Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Wed, 9 Dec 2020 11:38:25 +0100
Subject: [PATCH] Add select2 bug workaround for person-select as well

See #40
---
 packages/person-select/src/person-select.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/packages/person-select/src/person-select.js b/packages/person-select/src/person-select.js
index 97d258da..d91dd9ce 100644
--- a/packages/person-select/src/person-select.js
+++ b/packages/person-select/src/person-select.js
@@ -159,6 +159,8 @@ export class PersonSelect extends ScopedElementsMixin(LitElement) {
                     };
                 },
                 processResults: function (data) {
+                    that.$('#person-select-dropdown').addClass('select2-bug');
+
                     that.lastResult = data;
                     let transformed = that.jsonld.transformMembers(data, personContext);
                     const results = [];
@@ -176,6 +178,8 @@ export class PersonSelect extends ScopedElementsMixin(LitElement) {
                 }
             }
         }).on("select2:select", function (e) {
+            that.$('#person-select-dropdown').removeClass('select2-bug');
+
             // set custom element attributes
             const identifier = e.params.data.id;
             that.object = findObjectInApiResults(identifier, that.lastResult);
@@ -329,6 +333,11 @@ export class PersonSelect extends ScopedElementsMixin(LitElement) {
             .field .button.control dbp-icon {
                 top: 0;
             }
+
+            /* https://github.com/select2/select2/issues/5457 */
+            .select2-bug .loading-results {
+                display: none !important;
+            }
             `
         ];
     }
-- 
GitLab