mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
Fix ll-rebuild only keeps the card that should be deleted (#2481)
* Fix ll-rebuild only keeps the card that should be deleted * Do the same thing for stack cards. (Untested. Leeeeroyyyyy Jenkins) * Copy then replace instead of mutating * Use map
This commit is contained in:
parent
f943366ecd
commit
0ddc82601a
@ -75,15 +75,13 @@ export abstract class HuiStackCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _rebuildCard(
|
private _rebuildCard(
|
||||||
element: LovelaceCard,
|
cardElToReplace: LovelaceCard,
|
||||||
config: LovelaceCardConfig
|
config: LovelaceCardConfig
|
||||||
): void {
|
): void {
|
||||||
const newCard = this._createCardElement(config);
|
const newCardEl = this._createCardElement(config);
|
||||||
element.replaceWith(newCard);
|
cardElToReplace.parentElement!.replaceChild(newCardEl, cardElToReplace);
|
||||||
this._cards = this._cards!.splice(
|
this._cards = this._cards!.map((curCardEl) =>
|
||||||
this._cards!.indexOf(element),
|
curCardEl === cardElToReplace ? newCardEl : curCardEl
|
||||||
1,
|
|
||||||
newCard
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,12 +306,14 @@ export class HUIView extends hassLocalizeLitMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _rebuildCard(
|
private _rebuildCard(
|
||||||
element: LovelaceCard,
|
cardElToReplace: LovelaceCard,
|
||||||
config: LovelaceCardConfig
|
config: LovelaceCardConfig
|
||||||
): void {
|
): void {
|
||||||
const newCard = this._createCardElement(config);
|
const newCardEl = this._createCardElement(config);
|
||||||
element.parentElement!.replaceChild(newCard, element);
|
cardElToReplace.parentElement!.replaceChild(newCardEl, cardElToReplace);
|
||||||
this._cards = this._cards.splice(this._cards.indexOf(element), 1, newCard);
|
this._cards = this._cards!.map((curCardEl) =>
|
||||||
|
curCardEl === cardElToReplace ? newCardEl : curCardEl
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user