Skip to content

Commit 97df5a5

Browse files
authored
Key more-info details memoize on attribute name formatter (#53755)
_getDetailData caches on stateObj alone while formatting via this.hass, so results go stale when translation-based format functions reload (e.g. backend translations finishing after open, or a language switch) until the entity next changes state. Pass hass.formatEntityAttributeName as an extra memoize argument so the cache invalidates when format functions are recreated.
1 parent 19cd06b commit 97df5a5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/dialogs/more-info/ha-more-info-details.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ class HaMoreInfoDetails extends LitElement {
7373
stateEntries,
7474
attributes,
7575
yamlData: stateYamlData,
76-
} = this._getDetailData(this._stateObj);
76+
} = this._getDetailData(
77+
this._stateObj,
78+
this.hass.formatEntityAttributeName
79+
);
7780
const { floor, area, device } = getEntityContext(
7881
this._stateObj,
7982
this.hass.entities,
@@ -211,7 +214,10 @@ class HaMoreInfoDetails extends LitElement {
211214

212215
private _getDetailData = memoizeOne(
213216
(
214-
stateObj: HassEntity
217+
stateObj: HassEntity,
218+
// cache key only: a new function is assigned when translation-based
219+
// format functions reload, invalidating results formatted via this.hass
220+
_formatEntityAttributeName: HomeAssistant["formatEntityAttributeName"]
215221
): {
216222
stateEntries: DetailEntry[];
217223
attributes: { name: string; label: string }[];

0 commit comments

Comments
 (0)