Fix data-table group by unknown column (#24987)

This commit is contained in:
Paul Bottein 2025-04-09 17:51:02 +02:00 committed by GitHub
parent ddc04dd48a
commit 5f187c1bb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -204,10 +204,10 @@ export class HaTabsSubpageDataTable extends KeyboardShortcutMixin(LitElement) {
if (this.hasUpdated) { if (this.hasUpdated) {
return; return;
} }
if (this.initialGroupColumn) { if (this.initialGroupColumn && this.columns[this.initialGroupColumn]) {
this._setGroupColumn(this.initialGroupColumn); this._setGroupColumn(this.initialGroupColumn);
} }
if (this.initialSorting) { if (this.initialSorting && this.columns[this.initialSorting.column]) {
this._sortColumn = this.initialSorting.column; this._sortColumn = this.initialSorting.column;
this._sortDirection = this.initialSorting.direction; this._sortDirection = this.initialSorting.direction;
} }
@ -307,9 +307,10 @@ export class HaTabsSubpageDataTable extends KeyboardShortcutMixin(LitElement) {
<ha-md-button-menu positioning="popover"> <ha-md-button-menu positioning="popover">
<ha-assist-chip <ha-assist-chip
.label=${localize("ui.components.subpage-data-table.group_by", { .label=${localize("ui.components.subpage-data-table.group_by", {
groupColumn: this._groupColumn groupColumn:
? ` ${this.columns[this._groupColumn].title || this.columns[this._groupColumn].label}` this._groupColumn && this.columns[this._groupColumn]
: "", ? ` ${this.columns[this._groupColumn].title || this.columns[this._groupColumn].label}`
: "",
})} })}
slot="trigger" slot="trigger"
> >