From 8272bef8901ee84e5866c4a3f888e0bfcfd0113c Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 19 Jun 2024 08:31:04 -0700 Subject: [PATCH] Sort filter-domains on translated name (#21116) --- src/components/ha-filter-domains.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/ha-filter-domains.ts b/src/components/ha-filter-domains.ts index e7b0297199..88bd033998 100644 --- a/src/components/ha-filter-domains.ts +++ b/src/components/ha-filter-domains.ts @@ -89,13 +89,18 @@ export class HaFilterDomains extends LitElement { }); return Array.from(domains.values()) + .map((domain) => ({ + domain, + name: domainToName(this.hass.localize, domain), + })) .filter( (entry) => !filter || - entry.toLowerCase().includes(filter) || - domainToName(this.hass.localize, entry).toLowerCase().includes(filter) + entry.domain.toLowerCase().includes(filter) || + entry.name.toLowerCase().includes(filter) ) - .sort((a, b) => stringCompare(a, b, this.hass.locale.language)); + .sort((a, b) => stringCompare(a.name, b.name, this.hass.locale.language)) + .map((entry) => entry.domain); }); protected updated(changed) {