diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 7029ba4e3f..629cff5412 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -332,7 +332,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { "yaml-mode": this._mode === "yaml", })}" > - ${this._errors ? html`
${this._errors}
` : ""} ${this._mode === "gui" ? html`
+ ${this._errors + ? html` + + ${this._errors} + + ` + : ""}
${this._errors} + ` + : ""} = { + alias: values.alias ?? "", + icon: values.icon, + mode: values.mode, + max: isMaxMode(values.mode) ? values.max : undefined, + }; - for (const key of Object.keys(values)) { - if (key === "sequence") { + if (!this.scriptEntityId) { + this.updateEntityId(values.id, values.alias); + } + + for (const key of Object.keys(newValues)) { + const value = newValues[key]; + + if (value === this._config![key]) { continue; } - - const value = values[key]; - - if ( - value === this._config![key] || - (key === "id" && currentId === value) - ) { - continue; - } - - changed = true; - - switch (key) { - case "id": - this._idChanged(value); - break; - case "alias": - this._aliasChanged(value); - break; - case "mode": - this._modeChanged(value); - break; - } - - if (values[key] === undefined) { + if (value === undefined) { const newConfig = { ...this._config! }; delete newConfig![key]; this._config = newConfig; } else { this._config = { ...this._config!, [key]: value }; } + changed = true; } if (changed) { @@ -638,6 +640,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { private _configChanged(ev) { this._config = ev.detail.value; + this._errors = undefined; this._dirty = true; } @@ -759,7 +762,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { this.hass!.callApi("POST", "config/script/config/" + id, this._config).then( () => { this._dirty = false; - if (!this.scriptEntityId) { navigate(`/config/script/edit/${id}`, { replace: true }); } @@ -806,6 +808,10 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { max-width: 1040px; padding: 28px 20px 0; } + .config-container ha-alert { + margin-bottom: 16px; + display: block; + } ha-yaml-editor { flex-grow: 1; --code-mirror-height: 100%;