mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Fix automation drag&drop loses item (#25811)
This commit is contained in:
parent
634e1dbde8
commit
5b7655cf72
@ -235,7 +235,7 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
private async _actionAdded(ev: CustomEvent): Promise<void> {
|
private async _actionAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
const actions = [
|
let actions = [
|
||||||
...this.actions.slice(0, index),
|
...this.actions.slice(0, index),
|
||||||
data,
|
data,
|
||||||
...this.actions.slice(index),
|
...this.actions.slice(index),
|
||||||
@ -243,7 +243,15 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
// Add action locally to avoid UI jump
|
// Add action locally to avoid UI jump
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
await nextRender();
|
await nextRender();
|
||||||
fireEvent(this, "value-changed", { value: this.actions });
|
if (this.actions !== actions) {
|
||||||
|
// Ensure action is added even after update
|
||||||
|
actions = [
|
||||||
|
...this.actions.slice(0, index),
|
||||||
|
data,
|
||||||
|
...this.actions.slice(index),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
fireEvent(this, "value-changed", { value: actions });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _actionRemoved(ev: CustomEvent): Promise<void> {
|
private async _actionRemoved(ev: CustomEvent): Promise<void> {
|
||||||
|
@ -258,7 +258,7 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
private async _conditionAdded(ev: CustomEvent): Promise<void> {
|
private async _conditionAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
const conditions = [
|
let conditions = [
|
||||||
...this.conditions.slice(0, index),
|
...this.conditions.slice(0, index),
|
||||||
data,
|
data,
|
||||||
...this.conditions.slice(index),
|
...this.conditions.slice(index),
|
||||||
@ -266,7 +266,15 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
// Add condition locally to avoid UI jump
|
// Add condition locally to avoid UI jump
|
||||||
this.conditions = conditions;
|
this.conditions = conditions;
|
||||||
await nextRender();
|
await nextRender();
|
||||||
fireEvent(this, "value-changed", { value: this.conditions });
|
if (this.conditions !== conditions) {
|
||||||
|
// Ensure condition is added even after update
|
||||||
|
conditions = [
|
||||||
|
...this.conditions.slice(0, index),
|
||||||
|
data,
|
||||||
|
...this.conditions.slice(index),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
fireEvent(this, "value-changed", { value: conditions });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _conditionRemoved(ev: CustomEvent): Promise<void> {
|
private async _conditionRemoved(ev: CustomEvent): Promise<void> {
|
||||||
|
@ -220,7 +220,7 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
private async _triggerAdded(ev: CustomEvent): Promise<void> {
|
private async _triggerAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
const triggers = [
|
let triggers = [
|
||||||
...this.triggers.slice(0, index),
|
...this.triggers.slice(0, index),
|
||||||
data,
|
data,
|
||||||
...this.triggers.slice(index),
|
...this.triggers.slice(index),
|
||||||
@ -228,7 +228,15 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
// Add trigger locally to avoid UI jump
|
// Add trigger locally to avoid UI jump
|
||||||
this.triggers = triggers;
|
this.triggers = triggers;
|
||||||
await nextRender();
|
await nextRender();
|
||||||
fireEvent(this, "value-changed", { value: this.triggers });
|
if (this.triggers !== triggers) {
|
||||||
|
// Ensure trigger is added even after update
|
||||||
|
triggers = [
|
||||||
|
...this.triggers.slice(0, index),
|
||||||
|
data,
|
||||||
|
...this.triggers.slice(index),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
fireEvent(this, "value-changed", { value: triggers });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _triggerRemoved(ev: CustomEvent): Promise<void> {
|
private async _triggerRemoved(ev: CustomEvent): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user