From 3da638e720e9bfeef115640dad5ca998483e9624 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 19 Apr 2022 11:41:50 +0200
Subject: [PATCH] resource-select: initially show a a disabled select2 with a
 loading label

Not just when we aren't logged in. To avoid layout shifts.
---
 packages/resource-select/src/resource-select.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/packages/resource-select/src/resource-select.js b/packages/resource-select/src/resource-select.js
index 91c86ae9..e2a82db5 100644
--- a/packages/resource-select/src/resource-select.js
+++ b/packages/resource-select/src/resource-select.js
@@ -142,8 +142,14 @@ export class ResourceSelect extends AdapterLitElement {
 
     async _updateAll() {
         this._setValue(this.value);
-        if (!this.auth.token) {
+
+        // Show a dummy loading variant initially
+        const $select = this._getSelect2();
+        if (!this._IsSelect2Initialized($select)) {
             await this._setSelect2Loading();
+        }
+
+        if (!this.auth.token) {
             return;
         }
         await this._updateResources();
-- 
GitLab