Force editor rebuild on stack card switch

This commit is contained in:
Thomas Lovén 2022-05-31 11:39:56 +00:00
parent 498732566e
commit aecbfeaaa0
2 changed files with 10 additions and 1 deletions

View File

@ -167,6 +167,9 @@ export class HuiStackCardEditor
this._setMode(true);
this._guiModeAvailable = true;
this._selectedCard = parseInt(ev.detail.selected, 10);
if (this._cardEditorEl) {
this._cardEditorEl.forceRebuild = true;
}
}
protected _handleConfigChanged(ev: HASSDomEvent<ConfigChangedEvent>) {

View File

@ -53,6 +53,8 @@ export abstract class HuiElementEditor<T> extends LitElement {
@property({ attribute: false }) public lovelace?: LovelaceConfig;
public forceRebuild = false;
@state() private _yaml?: string;
@state() private _config?: T;
@ -292,7 +294,11 @@ export abstract class HuiElementEditor<T> extends LitElement {
this._errors = undefined;
this._warnings = undefined;
if (this._configElementType !== this.configElementType) {
if (
this._configElementType !== this.configElementType ||
this.forceRebuild
) {
this.forceRebuild = false;
// If the type has changed, we need to load a new GUI editor
this._guiSupported = undefined;
this._configElement = undefined;