Fix data-table sort by unknown column (#24965)

Fix database sort by unknown column
This commit is contained in:
Paul Bottein 2025-04-08 13:05:22 +02:00 committed by GitHub
parent 13aeb02b53
commit 9df5141aac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 13 deletions

View File

@ -645,15 +645,16 @@ export class HaDataTable extends LitElement {
return; return;
} }
const prom = this.sortColumn const prom =
? sortData( this.sortColumn && this._sortColumns[this.sortColumn]
filteredData, ? sortData(
this._sortColumns[this.sortColumn], filteredData,
this.sortDirection, this._sortColumns[this.sortColumn],
this.sortColumn, this.sortDirection,
this.hass.locale.language this.sortColumn,
) this.hass.locale.language
: filteredData; )
: filteredData;
const [data] = await Promise.all([prom, nextRender]); const [data] = await Promise.all([prom, nextRender]);

View File

@ -260,10 +260,11 @@ export class HaTabsSubpageDataTable extends KeyboardShortcutMixin(LitElement) {
<ha-assist-chip <ha-assist-chip
slot="trigger" slot="trigger"
.label=${localize("ui.components.subpage-data-table.sort_by", { .label=${localize("ui.components.subpage-data-table.sort_by", {
sortColumn: this._sortColumn sortColumn:
? ` ${this.columns[this._sortColumn]?.title || this.columns[this._sortColumn]?.label}` || this._sortColumn && this.columns[this._sortColumn]
"" ? ` ${this.columns[this._sortColumn].title || this.columns[this._sortColumn].label}` ||
: "", ""
: "",
})} })}
> >
<ha-svg-icon <ha-svg-icon