push: force release when widget is removed/recreated, prevent setting active state after editing
This commit is contained in:
parent
b9293786b6
commit
2414722ea1
3 changed files with 16 additions and 8 deletions
|
|
@ -63,7 +63,7 @@ var StateManager = class StateManager {
|
|||
|
||||
if (widgets[j].setValue) {
|
||||
|
||||
widgets[j].setValue(value, {send:send,sync:true})
|
||||
widgets[j].setValue(value, {send:send, sync:true, fromState:true})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ var StateManager = class StateManager {
|
|||
preset[id] = w.getProp('value')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.set(preset)
|
||||
|
||||
this.valueStateQueue = {}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Push extends Widget {
|
|||
super({...options, html: html`<div class="toggle"></div>`})
|
||||
|
||||
this.state = 0
|
||||
this.active = 0
|
||||
this.active = null
|
||||
this.lastChanged = 'state'
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
|
@ -76,7 +76,7 @@ class Push extends Widget {
|
|||
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
|
||||
this.widget.classList.add('active')
|
||||
this.container.classList.add('active')
|
||||
this.active = 1
|
||||
this.active = options
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue()
|
||||
|
|
@ -84,7 +84,7 @@ class Push extends Widget {
|
|||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.widget.classList.remove('active')
|
||||
this.container.classList.remove('active')
|
||||
this.active = 0
|
||||
this.active = null
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue(null, {syncOnly: this.getProp('norelease')})
|
||||
|
|
@ -96,9 +96,10 @@ class Push extends Widget {
|
|||
setValue(v,options={}) {
|
||||
|
||||
if (!options.fromExternal) {
|
||||
this.setValuePrivate(v,options)
|
||||
if (!options.fromState) this.setValuePrivate(v,options)
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof v == 'object' && v !== null) v = v.value
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
|
||||
this.widget.classList.add('on')
|
||||
|
|
@ -135,6 +136,12 @@ class Push extends Widget {
|
|||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
|
||||
if (this.active) this.setValuePrivate(this.getProp('off'), this.active)
|
||||
super.onRemove()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Push.dynamicProps = Push.prototype.constructor.dynamicProps.concat(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue