diff --git a/src/components/ha-control-slider.ts b/src/components/ha-control-slider.ts index eb4c2911ac..6b1d41addf 100644 --- a/src/components/ha-control-slider.ts +++ b/src/components/ha-control-slider.ts @@ -1,4 +1,4 @@ -import { DIRECTION_ALL, Manager, Pan, Tap } from "@egjs/hammerjs"; +import { DIRECTION_ALL, Manager, Pan, Press, Tap } from "@egjs/hammerjs"; import type { PropertyValues, TemplateResult } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, query, state } from "lit/decorators"; @@ -159,6 +159,7 @@ export class HaControlSlider extends LitElement { ); this._mc.add(new Tap({ event: "singletap" })); + this._mc.add(new Press()); let savedValue; this._mc.on("panstart", () => { @@ -190,7 +191,7 @@ export class HaControlSlider extends LitElement { fireEvent(this, "value-changed", { value: this.value }); }); - this._mc.on("singletap", (e) => { + this._mc.on("singletap pressup", (e) => { if (this.disabled) return; const percentage = this._getPercentageFromEvent(e); this.value = this.steppedValue(this.percentageToValue(percentage)); diff --git a/src/components/ha-control-switch.ts b/src/components/ha-control-switch.ts index 23838bb60e..d9984402d1 100644 --- a/src/components/ha-control-switch.ts +++ b/src/components/ha-control-switch.ts @@ -2,6 +2,7 @@ import { DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, Manager, + Press, Swipe, Tap, } from "@egjs/hammerjs"; @@ -79,6 +80,7 @@ export class HaControlSwitch extends LitElement { ); this._mc.add(new Tap({ event: "singletap" })); + this._mc.add(new Press()); if (this.vertical) { this._mc.on("swipeup", () => { @@ -106,10 +108,11 @@ export class HaControlSwitch extends LitElement { }); } - this._mc.on("singletap", () => { + this._mc.on("singletap pressup", () => { if (this.disabled) return; this._toggle(); }); + this.addEventListener("keydown", this._keydown); } }