Skip to content

Commit

Permalink
Handle falsy value in ha-yaml-editor (object selector)
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Sep 27, 2024
1 parent d7aaa41 commit 62f6357
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/components/ha-yaml-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ export class HaYamlEditor extends LitElement {

public setValue(value): void {
try {
this._yaml =
value && !isEmpty(value)
? dump(value, {
schema: this.yamlSchema,
quotingType: '"',
noRefs: true,
})
: "";
this._yaml = !isEmpty(value)
? dump(value, {
schema: this.yamlSchema,
quotingType: '"',
noRefs: true,
})
: "";
} catch (err: any) {
// eslint-disable-next-line no-console
console.error(err, value);
Expand All @@ -75,7 +74,7 @@ export class HaYamlEditor extends LitElement {
}

protected firstUpdated(): void {
if (this.defaultValue) {
if (this.defaultValue !== undefined) {
this.setValue(this.defaultValue);
}
}
Expand Down

0 comments on commit 62f6357

Please sign in to comment.