Fix passive color radius and fix switch label clicks#4703
Conversation
| private _haChangeHandler(e: Event) { | ||
| this.mdcFoundation.handleChange(e); | ||
| // catch "click" event and sync properties | ||
| this.checked = this.formElement.checked; |
There was a problem hiding this comment.
We shouldn't do this. This will lead to nasty bugs.
When a parent renders this element, it will diff against itself to know if it needs to change the property.
So let's say this happens:
- Parent renders checked = true
- User changes it, sets checked=false
- Parent renders checked = true -> this will not update
<ha-switch>because it already renderedtruelast time, even though the property current value isfalse
There was a problem hiding this comment.
This was actually a copy/paste from mwc-switch, because it was a private function
There was a problem hiding this comment.
It would be weird of the parent not to update it's value btw when the switch is changed.
There was a problem hiding this comment.
Also, there is no value-changed event, just the normal change event of the native checkbox, so it would be impossible for the parent to see what the state is when we would not update the prop? ev.target.checked would no longer work.
I could rewrite it and fire the value-changed event and not do this, but that would differ us a lot from mwc-switch and means a lot of change.
3025bdf to
0e7ee71
Compare
Fixes #4686