From bde93c44bd88102d2f2eddb105a4c664d4a53e99 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 2 Aug 2023 04:53:05 -0700 Subject: [PATCH] Fix statistic-picker filter behavior (#17453) --- src/components/entity/ha-statistic-picker.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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) {