Skip to content

Commit

Permalink
Fix vertical card editor
Browse files Browse the repository at this point in the history
Signed-off-by: Konrad Vité <[email protected]>
  • Loading branch information
kgraefe committed Oct 31, 2024
1 parent efd6877 commit 3a11cb8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions vertical-stack-in-card.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
console.log(`%cvertical-stack-in-card\n%cVersion: ${'0.4.4'}`, 'color: #1976d2; font-weight: bold;', '');

const HELPERS = window.loadCardHelpers ? window.loadCardHelpers() : undefined;

class VerticalStackInCard extends HTMLElement {
constructor() {
super();
Expand Down Expand Up @@ -181,8 +183,16 @@ class VerticalStackInCard extends HTMLElement {
return sizes.reduce((a, b) => a + b, 0);
}

static getConfigElement() {
return customElements.get('hui-vertical-stack-card').getConfigElement();
static async getConfigElement() {
// Ensure hui-card-element-editor and hui-card-picker are loaded.
// They happen to be used by the vertical-stack card editor but there must be a better way?
let cls = customElements.get('hui-vertical-stack-card');
if (!cls) {
(await HELPERS).createCardElement({ type: 'vertical-stack', cards: [] });
await customElements.whenDefined('hui-vertical-stack-card');
cls = customElements.get('hui-vertical-stack-card');
}
return cls.getConfigElement();
}

static getStubConfig() {
Expand Down

0 comments on commit 3a11cb8

Please sign in to comment.