From 640fbd616b83ae240f20588ad1ef859ee98b5292 Mon Sep 17 00:00:00 2001 From: Pascal Roeleven Date: Wed, 25 Aug 2021 19:55:16 +0200 Subject: [PATCH] Prevent possible parent action-row from switching to yamlMode (#9883) * Prevent possible parent action-row from switching to yamlMode Now that we have the choose-action, it's possible to have nested action-rows. If an action contains a template, we should only switch that action-row to yamlMode instead of all action-rows. By canceling the bubbling on the first encouter we prevent the event from bubbling upwards to parent action-rows. * Prevent possible parent action-row from also moving Now that we have the choose-action, it's possible to have nested action-rows. If an action inside a choose-action is moved, we should only move that action-row instead of both the action-row and its parents. By canceling the bubbling on the first encouter we prevent the event from bubbling upwards to parent action-rows. * Apply suggestions from code review Co-authored-by: Paulus Schoutsen --- .../config/automation/action/ha-automation-action-row.ts | 3 +++ src/panels/config/automation/action/ha-automation-action.ts | 3 +++ 2 files changed, 6 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 96719a003f..05fdbe4cf3 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -252,6 +252,9 @@ export default class HaAutomationActionRow extends LitElement { } private _handleUiModeNotAvailable(ev: CustomEvent) { + // Prevent possible parent action-row from switching to yamlMode + ev.stopPropagation(); + this._warnings = handleStructError(this.hass, ev.detail).warnings; if (!this._yamlMode) { this._yamlMode = true; diff --git a/src/panels/config/automation/action/ha-automation-action.ts b/src/panels/config/automation/action/ha-automation-action.ts index dfdf25b215..a51749e902 100644 --- a/src/panels/config/automation/action/ha-automation-action.ts +++ b/src/panels/config/automation/action/ha-automation-action.ts @@ -53,6 +53,9 @@ export default class HaAutomationAction extends LitElement { } private _move(ev: CustomEvent) { + // Prevent possible parent action-row from also moving + ev.stopPropagation(); + const index = (ev.target as any).index; const newIndex = ev.detail.direction === "up" ? index - 1 : index + 1; const actions = this.actions.concat();