mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Add work around for Safari paper-toggle-button update issue (#387)
* Add work around for Safari paper-toggle-button bug * Lint
This commit is contained in:
parent
9426cfd5ca
commit
f5781a9906
@ -28,7 +28,7 @@
|
|||||||
<paper-icon-button icon="mdi:flash" on-tap="turnOn" state-active$='[[isOn]]'></paper-icon-button>
|
<paper-icon-button icon="mdi:flash" on-tap="turnOn" state-active$='[[isOn]]'></paper-icon-button>
|
||||||
</template>
|
</template>
|
||||||
<template is='dom-if' if='[[!stateObj.attributes.assumed_state]]'>
|
<template is='dom-if' if='[[!stateObj.attributes.assumed_state]]'>
|
||||||
<paper-toggle-button class='self-center'
|
<paper-toggle-button
|
||||||
checked="[[toggleChecked]]"
|
checked="[[toggleChecked]]"
|
||||||
on-change="toggleChanged"></paper-toggle-button>
|
on-change="toggleChanged"></paper-toggle-button>
|
||||||
</template>
|
</template>
|
||||||
@ -75,6 +75,14 @@ Polymer({
|
|||||||
toggleChanged: function (ev) {
|
toggleChanged: function (ev) {
|
||||||
var newVal = ev.target.checked;
|
var newVal = ev.target.checked;
|
||||||
|
|
||||||
|
// HACK: https://github.com/PolymerElements/paper-toggle-button/issues/124
|
||||||
|
setTimeout(function () {
|
||||||
|
const el = document.activeElement;
|
||||||
|
el.blur();
|
||||||
|
el.focus();
|
||||||
|
}, 0);
|
||||||
|
// END HACK
|
||||||
|
|
||||||
if (newVal && !this.isOn) {
|
if (newVal && !this.isOn) {
|
||||||
this.callService(true);
|
this.callService(true);
|
||||||
} else if (!newVal && this.isOn) {
|
} else if (!newVal && this.isOn) {
|
||||||
@ -84,6 +92,15 @@ Polymer({
|
|||||||
|
|
||||||
isOnChanged: function (newVal) {
|
isOnChanged: function (newVal) {
|
||||||
this.toggleChecked = newVal;
|
this.toggleChecked = newVal;
|
||||||
|
|
||||||
|
// HACK: https://github.com/PolymerElements/paper-toggle-button/issues/124
|
||||||
|
var el = this.shadowRoot.querySelector('paper-toggle-button');
|
||||||
|
|
||||||
|
if (el) {
|
||||||
|
el.focus();
|
||||||
|
el.blur();
|
||||||
|
}
|
||||||
|
// END HACK
|
||||||
},
|
},
|
||||||
|
|
||||||
forceStateChange: function () {
|
forceStateChange: function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user