Skip to content

Commit

Permalink
fix: Attempt to improve editor reliability
Browse files Browse the repository at this point in the history
Use a copy of this.config in valueChanged, considering the passed config
might be frozen

Ref #233
  • Loading branch information
nervetattoo committed May 11, 2021
1 parent 09a957b commit 50cf021
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,19 @@ export default class SimpleThermostatEditor extends LitElement {
return
}
const { target } = ev
const copy = { ...this.config }
if (target.configValue) {
if (target.value === '') {
delete this.config[target.configValue]
delete copy[target.configValue]
} else {
setValue(
this.config,
copy,
target.configValue,
target.checked !== undefined ? target.checked : target.value
)
}
}
fireEvent(this, 'config-changed', { config: this.config })
fireEvent(this, 'config-changed', { config: copy })
}

toggleHeader(ev) {
Expand Down

0 comments on commit 50cf021

Please sign in to comment.