Skip to content

Commit

Permalink
Preserve alias at the row level
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Oct 4, 2023
1 parent e9fe125 commit 55e3768
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
14 changes: 13 additions & 1 deletion src/panels/config/automation/action/ha-automation-action-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ export default class HaAutomationActionRow extends LitElement {
></ha-yaml-editor>
`
: html`
<div @ui-mode-not-available=${this._handleUiModeNotAvailable}>
<div
@ui-mode-not-available=${this._handleUiModeNotAvailable}
@value-changed=${this._onUiChanged}
>
${dynamicElement(`ha-automation-action-${type}`, {
hass: this.hass,
action: this.action,
Expand Down Expand Up @@ -530,6 +533,15 @@ export default class HaAutomationActionRow extends LitElement {
fireEvent(this, "value-changed", { value: ev.detail.value });
}

private _onUiChanged(ev: CustomEvent) {
ev.stopPropagation();
const value = {
alias: this.action.alias,
...ev.detail.value,
};
fireEvent(this, "value-changed", { value });
}

private _switchUiMode() {
this._warnings = undefined;
this._yamlMode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,10 @@ export class HaServiceAction extends LitElement implements ActionElement {
}

private _actionChanged(ev) {
ev.stopPropagation();
const serviceChanged = this._action?.service !== ev.detail.value?.service;

// Clean old fields except alias if service changed
const oldAction = serviceChanged
? {
alias: this._action?.alias,
}
: this.action;

const value = { ...oldAction, ...ev.detail.value };
if (ev.detail.value === this._action) {
ev.stopPropagation();
}
const value = { ...this.action, ...ev.detail.value };

if ("response_variable" in this.action) {
const [domain, service] = this._action!.service
Expand Down

0 comments on commit 55e3768

Please sign in to comment.