From 5317a11c396b9727c1e46aafe5598296b95205f9 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:32:35 -0700 Subject: [PATCH] Sort custom cards in card picker (#20517) --- .../editor/card-editor/hui-card-picker.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/panels/lovelace/editor/card-editor/hui-card-picker.ts b/src/panels/lovelace/editor/card-editor/hui-card-picker.ts index 2577822756e9..e92aba044dbe 100644 --- a/src/panels/lovelace/editor/card-editor/hui-card-picker.ts +++ b/src/panels/lovelace/editor/card-editor/hui-card-picker.ts @@ -278,13 +278,21 @@ export class HuiCardPicker extends LitElement { if (customCards.length > 0) { cards = cards.concat( - customCards.map((ccard: CustomCardEntry) => ({ - type: ccard.type, - name: ccard.name, - description: ccard.description, - showElement: ccard.preview, - isCustom: true, - })) + customCards + .map((ccard: CustomCardEntry) => ({ + type: ccard.type, + name: ccard.name, + description: ccard.description, + showElement: ccard.preview, + isCustom: true, + })) + .sort((a, b) => + stringCompare( + a.name || a.type, + b.name || b.type, + this.hass?.language + ) + ) ); } this._cards = cards.map((card: Card) => ({