1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Fix calendar card not showing different colors for multiple calendars (#28338)

This commit is contained in:
Petar Petrov
2025-12-05 14:39:51 +02:00
committed by GitHub
parent 92e3864f63
commit ef82bc2abb

View File

@@ -80,12 +80,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
throw new Error("Entities need to be an array");
}
const computedStyles = getComputedStyle(this);
this._calendars = config!.entities.map((entity, idx) => ({
entity_id: entity,
backgroundColor: getColorByIndex(idx, computedStyles),
}));
if (this._config?.entities !== config.entities) {
this._fetchCalendarEvents();
}
@@ -93,6 +87,20 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
this._config = { initial_view: "dayGridMonth", ...config };
}
public willUpdate(changedProps: PropertyValues): void {
super.willUpdate(changedProps);
if (
!this.hasUpdated ||
(changedProps.has("_config") && this._config?.entities)
) {
const computedStyles = getComputedStyle(this);
this._calendars = this._config!.entities.map((entity, idx) => ({
entity_id: entity,
backgroundColor: getColorByIndex(idx, computedStyles),
}));
}
}
public getCardSize(): number {
return 12;
}