From 68a0d04f0428a855022def6aece87157e10950f6 Mon Sep 17 00:00:00 2001 From: Martin Dybal Date: Fri, 13 Sep 2024 09:59:04 +0200 Subject: [PATCH] Added hold and double tap actions for tile card icon (#21947) --- src/panels/lovelace/cards/hui-tile-card.ts | 9 +++++++-- src/panels/lovelace/cards/types.ts | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/cards/hui-tile-card.ts b/src/panels/lovelace/cards/hui-tile-card.ts index c015c22f3c57..7de87b1c92e8 100644 --- a/src/panels/lovelace/cards/hui-tile-card.ts +++ b/src/panels/lovelace/cards/hui-tile-card.ts @@ -136,8 +136,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard { const config = { entity: this._config!.entity, tap_action: this._config!.icon_tap_action, + hold_action: this._config!.icon_hold_action, + double_tap_action: this._config!.icon_double_tap_action, }; - handleAction(this, this.hass!, config, "tap"); + handleAction(this, this.hass!, config, ev.detail.action!); } private _getImageUrl(entity: HassEntity): string | undefined { @@ -286,7 +288,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard { role=${ifDefined(this.hasIconAction ? "button" : undefined)} tabindex=${ifDefined(this.hasIconAction ? "0" : undefined)} @action=${this._handleIconAction} - .actionHandler=${actionHandler()} + .actionHandler=${actionHandler({ + hasHold: hasAction(this._config!.icon_hold_action), + hasDoubleClick: hasAction(this._config!.icon_double_tap_action), + })} > ${imageUrl ? html` diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 8bf731f56d8b..0721fe8a9d47 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -498,5 +498,7 @@ export interface TileCardConfig extends LovelaceCardConfig { hold_action?: ActionConfig; double_tap_action?: ActionConfig; icon_tap_action?: ActionConfig; + icon_hold_action?: ActionConfig; + icon_double_tap_action?: ActionConfig; features?: LovelaceCardFeatureConfig[]; }