Fix Markdown cards in Grid not taking full height (#23121)

The implementation of show_empty property in #21379 introduced
regression which causes Markdown cards rendered within a Grid card to
not take full height of its space. This is because a visible card is now
forced to have "display: block", while without that it's rendered as
"display: inline".

As the CSSStyleDeclaration.style mandates string type, it's not possible
to delete or null the value. Setting it to an empty string seems to do
the trick as well and the linter is happy too.

Fixes #23119
This commit is contained in:
Jan Čermák 2024-12-03 17:33:59 +01:00 committed by GitHub
parent 8e6f4886e8
commit 6126280f2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,7 +111,7 @@ export class HuiMarkdownCard extends LitElement implements LovelaceCard {
this._config.show_empty === false &&
this._templateResult.result.length === 0;
if (shouldBeHidden !== this.hidden) {
this.style.display = shouldBeHidden ? "none" : "block";
this.style.display = shouldBeHidden ? "none" : "";
this.toggleAttribute("hidden", shouldBeHidden);
fireEvent(this, "card-visibility-changed", { value: !shouldBeHidden });
}