diff --git a/src/components/entity/ha-statistic-picker.ts b/src/components/entity/ha-statistic-picker.ts index e9a9388243..3a46527766 100644 --- a/src/components/entity/ha-statistic-picker.ts +++ b/src/components/entity/ha-statistic-picker.ts @@ -1,5 +1,5 @@ import { HassEntity } from "home-assistant-js-websocket"; -import { html, LitElement, PropertyValues, TemplateResult } from "lit"; +import { html, LitElement, nothing, PropertyValues, TemplateResult } from "lit"; import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit"; import { customElement, property, query, state } from "lit/decorators"; import memoizeOne from "memoize-one"; @@ -87,6 +87,8 @@ export class HaStatisticPicker extends LitElement { private _statistics: StatisticItem[] = []; + @state() private _filteredItems?: StatisticItem[] = undefined; + private _rowRenderer: ComboBoxLitRenderer = (item) => html` ${item.state @@ -254,7 +256,11 @@ export class HaStatisticPicker extends LitElement { } } - protected render(): TemplateResult { + protected render(): TemplateResult | typeof nothing { + if (this._statistics.length === 0) { + return nothing; + } + return html` (filterString, this._statistics) - : this._statistics; + : undefined; } private _setValue(value: string) {