diff --git a/src/panels/lovelace/cards/hui-glance-card.ts b/src/panels/lovelace/cards/hui-glance-card.ts index 59e31cb15f..4d3d577de6 100644 --- a/src/panels/lovelace/cards/hui-glance-card.ts +++ b/src/panels/lovelace/cards/hui-glance-card.ts @@ -66,17 +66,15 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard { private _configEntities?: GlanceConfigEntity[]; public getCardSize(): number { - return ( - (this._config!.title ? 1 : 0) + - Math.max( - ((this._config!.show_icon ? 1 : 0) + - (this._config!.show_name && this._config!.show_state ? 1 : 0)) * - Math.ceil( - this._configEntities!.length / (this._config!.columns || 5) - ), - 1 - ) + const rowHeight = + (this._config!.show_icon ? 1 : 0) + + (this._config!.show_name && this._config!.show_state ? 1 : 0) || 1; + + const numRows = Math.ceil( + this._configEntities!.length / (this._config!.columns || 5) ); + + return (this._config!.title ? 1 : 0) + rowHeight * numRows; } public setConfig(config: GlanceCardConfig): void {