Prevent uncaught TypeError on HuiWeatherForecastCard render (#26038)

This commit is contained in:
Ezra Freedman 2025-07-03 15:19:48 -04:00 committed by Bram Kragten
parent 70c5f77aa7
commit 0ed2b5966e

View File

@ -243,11 +243,11 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
); );
let itemsToShow = this._config?.forecast_slots ?? 5; let itemsToShow = this._config?.forecast_slots ?? 5;
if (this._sizeController.value.width === "very-very-narrow") { if (this._sizeController.value?.width === "very-very-narrow") {
itemsToShow = Math.min(3, itemsToShow); itemsToShow = Math.min(3, itemsToShow);
} else if (this._sizeController.value.width === "very-narrow") { } else if (this._sizeController.value?.width === "very-narrow") {
itemsToShow = Math.min(5, itemsToShow); itemsToShow = Math.min(5, itemsToShow);
} else if (this._sizeController.value.width === "narrow") { } else if (this._sizeController.value?.width === "narrow") {
itemsToShow = Math.min(7, itemsToShow); itemsToShow = Math.min(7, itemsToShow);
} }
@ -266,8 +266,12 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
return html` return html`
<ha-card <ha-card
class=${classMap({ class=${classMap({
[this._sizeController.value.height]: true, [this._sizeController.value?.height]: Boolean(
[this._sizeController.value.width]: true, this._sizeController.value
),
[this._sizeController.value?.width]: Boolean(
this._sizeController.value
),
})} })}
@action=${this._handleAction} @action=${this._handleAction}
.actionHandler=${actionHandler({ .actionHandler=${actionHandler({