Sort custom cards in card picker (#20517)

This commit is contained in:
karwosts 2024-04-14 13:32:35 -07:00 committed by GitHub
parent 27c53b3241
commit 5317a11c39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -278,13 +278,21 @@ export class HuiCardPicker extends LitElement {
if (customCards.length > 0) { if (customCards.length > 0) {
cards = cards.concat( cards = cards.concat(
customCards.map((ccard: CustomCardEntry) => ({ customCards
.map((ccard: CustomCardEntry) => ({
type: ccard.type, type: ccard.type,
name: ccard.name, name: ccard.name,
description: ccard.description, description: ccard.description,
showElement: ccard.preview, showElement: ccard.preview,
isCustom: true, isCustom: true,
})) }))
.sort((a, b) =>
stringCompare(
a.name || a.type,
b.name || b.type,
this.hass?.language
)
)
); );
} }
this._cards = cards.map((card: Card) => ({ this._cards = cards.map((card: Card) => ({