Compare commits

..

1 Commits

Author SHA1 Message Date
Aidan Timson f241c953b3 Fix editor context 2026-06-03 14:17:30 +01:00
@@ -142,21 +142,42 @@ export const AutomationScriptEditorMixin = <TConfig extends BaseEditorConfig>(
value: PromiseLike<EntityRegistryEntry> | EntityRegistryEntry
) => void;
private _relatedContextAreaId?: string;
protected willUpdate(changedProps: PropertyValues): void {
super.willUpdate(changedProps);
if (changedProps.has("registryEntry")) {
const areaId = this.registryEntry?.area_id;
if (areaId) {
fireEvent(this, "hass-related-context", {
itemType: "area",
itemId: areaId,
});
} else {
fireEvent(this, "hass-related-context", undefined);
}
if (
changedProps.has("currentEntityId") ||
changedProps.has("entityRegistry")
) {
this._setRelatedContext();
}
}
private _setRelatedContext(): void {
const areaId = this.currentEntityId
? this.entityRegistry?.find(
({ entity_id }) => entity_id === this.currentEntityId
)?.area_id || undefined
: undefined;
if (areaId === this._relatedContextAreaId) {
return;
}
this._relatedContextAreaId = areaId;
fireEvent(
this,
"hass-related-context",
areaId
? {
itemType: "area",
itemId: areaId,
}
: undefined
);
}
protected renderLoading(): TemplateResult {
return html`
<ha-fade-in .delay=${500}>