From 0fcedc50465372900111423833dee7a39fd2a4f7 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 5 Jun 2020 23:46:16 +0200 Subject: [PATCH] Glance height fix (Again): A row could be zero height (#6110) --- src/panels/lovelace/cards/hui-glance-card.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 {