diff --git a/src/panels/lovelace/common/directives/action-handler-directive.ts b/src/panels/lovelace/common/directives/action-handler-directive.ts index 54fdf11055..e9f9597b9e 100644 --- a/src/panels/lovelace/common/directives/action-handler-directive.ts +++ b/src/panels/lovelace/common/directives/action-handler-directive.ts @@ -111,12 +111,10 @@ class ActionHandler extends HTMLElement implements ActionHandler { y = (ev as MouseEvent).pageY; } - if (options.hasHold) { - this.timer = window.setTimeout(() => { - this.startAnimation(x, y); - this.held = true; - }, this.holdTime); - } + this.timer = window.setTimeout(() => { + this.startAnimation(x, y); + this.held = true; + }, this.holdTime); this.cooldownStart = true; window.setTimeout(() => (this.cooldownStart = false), 100); @@ -166,7 +164,7 @@ class ActionHandler extends HTMLElement implements ActionHandler { // That might be a bug, but until it's fixed, this should make action-handler work. // If it's not a bug that is fixed, this might need updating with the next iOS version. // Note that all events (both touch and mouse) must be listened for in order to work on computers with both mouse and touchscreen. - const isIOS13 = window.navigator.userAgent.match(/iPhone OS 13_/); + const isIOS13 = /iPhone OS 13_/.test(window.navigator.userAgent); if (!isIOS13) { element.addEventListener("mousedown", clickStart, { passive: true }); element.addEventListener("click", clickEnd); @@ -193,7 +191,7 @@ class ActionHandler extends HTMLElement implements ActionHandler { customElements.define("action-handler", ActionHandler); -const geActionHandler = (): ActionHandler => { +const getActionHandler = (): ActionHandler => { const body = document.body; if (body.querySelector("action-handler")) { return body.querySelector("action-handler") as ActionHandler; @@ -209,7 +207,7 @@ export const actionHandlerBind = ( element: ActionHandlerElement, options: ActionHandlerOptions ) => { - const actionhandler: ActionHandler = geActionHandler(); + const actionhandler: ActionHandler = getActionHandler(); if (!actionhandler) { return; }