Reload the card when changing the configuration in editor (#21351)

This commit is contained in:
Paul Bottein 2024-07-10 12:39:50 +02:00 committed by GitHub
parent 7edc4efc95
commit daa36788e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -150,8 +150,10 @@ export class HuiCard extends ReactiveElement {
if (changedProps.has("config")) {
const elementConfig = this._elementConfig;
if (this.config !== elementConfig && this.config) {
const typeChanged = this.config?.type !== elementConfig?.type;
if (typeChanged) {
const typeChanged =
this.config?.type !== elementConfig?.type || this.preview;
// Rebuild the card if the type of the card has changed or if we are in preview mode
if (typeChanged || this.preview) {
this._loadElement(this.config);
} else {
this._updateElement(this.config);