From 4a61779aba2ab73e23e103cc47bb84b5cb266a9f Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Mon, 4 Jan 2021 15:01:25 +0100 Subject: [PATCH] Ensure YAML editor gets updated during action change / deletion (#8024) Co-authored-by: Bram Kragten --- .../config/automation/action/ha-automation-action-row.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index 4cc20c8c04..9644803d3d 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -15,12 +15,14 @@ import { LitElement, property, PropertyValues, + query, } from "lit-element"; import { dynamicElement } from "../../../../common/dom/dynamic-element-directive"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button-menu"; import "../../../../components/ha-card"; import "../../../../components/ha-svg-icon"; +import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; import type { Action } from "../../../../data/script"; import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; import { haStyle } from "../../../../resources/styles"; @@ -103,6 +105,8 @@ export default class HaAutomationActionRow extends LitElement { @internalProperty() private _yamlMode = false; + @query("ha-yaml-editor") private _yamlEditor?: HaYamlEditor; + protected updated(changedProperties: PropertyValues) { if (!changedProperties.has("action")) { return; @@ -111,6 +115,10 @@ export default class HaAutomationActionRow extends LitElement { if (!this._uiModeAvailable && !this._yamlMode) { this._yamlMode = true; } + + if (this._yamlMode && this._yamlEditor) { + this._yamlEditor.setValue(this.action); + } } protected render() {