From e764076b1af8f70695afda5aa43925bcf35daa67 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Mon, 21 Aug 2023 06:48:10 -0700 Subject: [PATCH] Fix blueprint editor behavior for number and text with defaults (#17646) --- .../automation/blueprint-automation-editor.ts | 50 ++++++------------- .../config/script/blueprint-script-editor.ts | 46 +++++------------ 2 files changed, 28 insertions(+), 68 deletions(-) diff --git a/src/panels/config/automation/blueprint-automation-editor.ts b/src/panels/config/automation/blueprint-automation-editor.ts index 74d3d0586e..a860e29481 100644 --- a/src/panels/config/automation/blueprint-automation-editor.ts +++ b/src/panels/config/automation/blueprint-automation-editor.ts @@ -9,7 +9,6 @@ import "../../../components/ha-circular-progress"; import "../../../components/ha-markdown"; import "../../../components/ha-selector/ha-selector"; import "../../../components/ha-settings-row"; -import "../../../components/ha-textfield"; import "../../../components/ha-alert"; import { BlueprintAutomationConfig } from "../../../data/automation"; import { @@ -129,27 +128,19 @@ export class HaBlueprintAutomationEditor extends LitElement { breaks .content=${value?.description} > - ${value?.selector - ? html`` - : html``} + ${html``} ` ) : html`

@@ -173,7 +164,7 @@ export class HaBlueprintAutomationEditor extends LitElement { } fireEvent(this, "value-changed", { value: { - ...this.config!, + ...this.config, use_blueprint: { path: ev.detail.value, }, @@ -195,20 +186,9 @@ export class HaBlueprintAutomationEditor extends LitElement { } const input = { ...this.config.use_blueprint.input, [key]: value }; - const blueprint = this._blueprint; - const metaValue = - !blueprint || "error" in blueprint - ? undefined - : blueprint?.metadata.input && blueprint?.metadata?.input[key]; - const keyDefault = metaValue && metaValue.default; - - if ((value === "" && !keyDefault) || value === undefined) { - delete input[key]; - } - fireEvent(this, "value-changed", { value: { - ...this.config!, + ...this.config, use_blueprint: { ...this.config.use_blueprint, input, diff --git a/src/panels/config/script/blueprint-script-editor.ts b/src/panels/config/script/blueprint-script-editor.ts index 7a71170b98..a47b16b727 100644 --- a/src/panels/config/script/blueprint-script-editor.ts +++ b/src/panels/config/script/blueprint-script-editor.ts @@ -5,7 +5,6 @@ import "../../../components/ha-blueprint-picker"; import "../../../components/ha-card"; import "../../../components/ha-circular-progress"; import "../../../components/ha-markdown"; -import "../../../components/ha-textfield"; import "../../../components/ha-selector/ha-selector"; import "../../../components/ha-settings-row"; @@ -108,27 +107,19 @@ export class HaBlueprintScriptEditor extends LitElement { breaks .content=${value?.description} > - ${value?.selector - ? html`` - : html``} + ${html``} ` ) : html`

@@ -174,17 +165,6 @@ export class HaBlueprintScriptEditor extends LitElement { } const input = { ...this.config.use_blueprint.input, [key]: value }; - const blueprint = this._blueprint; - const metaValue = - !blueprint || "error" in blueprint - ? undefined - : blueprint?.metadata.input && blueprint?.metadata?.input[key]; - const keyDefault = metaValue && metaValue.default; - - if ((value === "" && !keyDefault) || value === undefined) { - delete input[key]; - } - fireEvent(this, "value-changed", { value: { ...this.config,