Fix blueprint script editor defaults handling (#16196)

This commit is contained in:
karwosts 2023-05-31 03:58:22 -07:00 committed by GitHub
parent 648383addd
commit 046475e7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -194,7 +194,14 @@ export class HaBlueprintAutomationEditor extends LitElement {
}
const input = { ...this.config.use_blueprint.input, [key]: value };
if (value === "" || value === undefined) {
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];
}

View File

@ -173,7 +173,14 @@ export class HaBlueprintScriptEditor extends LitElement {
}
const input = { ...this.config.use_blueprint.input, [key]: value };
if (value === "" || value === undefined) {
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];
}