From ee57f26415d087bbffbb61321335d1778df262d8 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 30 Dec 2023 18:39:21 +0100 Subject: [PATCH] Sort domains correctly, scroll to top on back (#19197) --- .../add-automation-element-dialog.ts | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/panels/config/automation/add-automation-element-dialog.ts b/src/panels/config/automation/add-automation-element-dialog.ts index f05d9ef3fe..b96283a61d 100644 --- a/src/panels/config/automation/add-automation-element-dialog.ts +++ b/src/panels/config/automation/add-automation-element-dialog.ts @@ -254,31 +254,29 @@ class DialogAddAutomationElement extends LitElement implements HassDialog { return []; } const result: ListItem[] = []; - Object.keys(services) - .sort() - .forEach((domain) => { - const manifest = manifests[domain]; - if ( - (type === undefined && - manifest?.integration_type === "entity" && - !ENTITY_DOMAINS_OTHER.has(domain)) || - (type === "helper" && manifest?.integration_type === "helper") || - (type === "other" && - (ENTITY_DOMAINS_OTHER.has(domain) || - !["helper", "entity"].includes( - manifest?.integration_type || "" - ))) - ) { - result.push({ - group: true, - icon: domainIcon(domain), - key: `${SERVICE_PREFIX}${domain}`, - name: domainToName(localize, domain, manifest), - description: "", - }); - } - }); - return result; + Object.keys(services).forEach((domain) => { + const manifest = manifests[domain]; + if ( + (type === undefined && + manifest?.integration_type === "entity" && + !ENTITY_DOMAINS_OTHER.has(domain)) || + (type === "helper" && manifest?.integration_type === "helper") || + (type === "other" && + (ENTITY_DOMAINS_OTHER.has(domain) || + !["helper", "entity"].includes(manifest?.integration_type || ""))) + ) { + result.push({ + group: true, + icon: domainIcon(domain), + key: `${SERVICE_PREFIX}${domain}`, + name: domainToName(localize, domain, manifest), + description: "", + }); + } + }); + return result.sort((a, b) => + stringCompare(a.name, b.name, this.hass.locale.language) + ); } ); @@ -515,6 +513,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog { } private _back() { + this._dialog!.scrollToPos(0, 0); if (this._filter) { this._filter = ""; return;