Fix dirty check/leaving automation editor (#10211)

This commit is contained in:
Bram Kragten 2021-10-08 20:32:13 +02:00
parent b157cf5294
commit 5be475ea17
No known key found for this signature in database
GPG Key ID: FBE2DFDB363EF55B
5 changed files with 14 additions and 6 deletions

View File

@ -443,7 +443,9 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
),
confirmText: this.hass!.localize("ui.common.leave"),
dismissText: this.hass!.localize("ui.common.stay"),
confirm: () => history.back(),
confirm: () => {
setTimeout(() => history.back());
},
});
} else {
history.back();

View File

@ -267,7 +267,10 @@ export class HaManualAutomationEditor extends LitElement {
const mode = ((ev.target as PaperListboxElement)?.selectedItem as any)
?.mode;
if (mode === this.config!.mode) {
if (
mode === this.config!.mode ||
(!this.config!.mode && mode === MODES[0])
) {
return;
}
const value = {

View File

@ -263,7 +263,7 @@ export default class HaAutomationTriggerRow extends LitElement {
private _idChanged(ev: CustomEvent) {
const newId = ev.detail.value;
if (newId === this.trigger.id) {
if (newId === (this.trigger.id ?? "")) {
return;
}
const value = { ...this.trigger };

View File

@ -555,7 +555,7 @@ export class HaSceneEditor extends SubscribeMixin(
try {
config = await getSceneConfig(this.hass, this.sceneId!);
} catch (err: any) {
showAlertDialog(this, {
await showAlertDialog(this, {
text:
err.status_code === 404
? this.hass.localize(
@ -566,7 +566,8 @@ export class HaSceneEditor extends SubscribeMixin(
"err_no",
err.status_code
),
}).then(() => history.back());
});
history.back();
return;
}

View File

@ -586,7 +586,9 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
),
confirmText: this.hass!.localize("ui.common.leave"),
dismissText: this.hass!.localize("ui.common.stay"),
confirm: () => history.back(),
confirm: () => {
setTimeout(() => history.back());
},
});
} else {
history.back();