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 <paulus@home-assistant.io>
This commit is contained in:
Pascal Roeleven 2021-08-25 19:55:16 +02:00 committed by GitHub
parent 900efe8a36
commit 640fbd616b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -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;

View File

@ -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();