From 67022b9ffc325225c0b9fd080e7d2b1b7b30412d Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Fri, 17 Jan 2020 15:39:24 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20make=20picture=20card=20tabbable?= =?UTF-8?q?=20only=20if=20action=20set=20(#4494)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 make picture card tabbable only if action set * 👌use ifDefined and hasAction * ✏️ fix syntax mistake --- src/panels/lovelace/cards/hui-picture-card.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/cards/hui-picture-card.ts b/src/panels/lovelace/cards/hui-picture-card.ts index c649deef2c..c34577bf02 100644 --- a/src/panels/lovelace/cards/hui-picture-card.ts +++ b/src/panels/lovelace/cards/hui-picture-card.ts @@ -20,6 +20,7 @@ import { actionHandler } from "../common/directives/action-handler-directive"; import { hasAction } from "../common/has-action"; import { ActionHandlerEvent } from "../../../data/lovelace"; import { handleAction } from "../common/handle-action"; +import { ifDefined } from "lit-html/directives/if-defined"; @customElement("hui-picture-card") export class HuiPictureCard extends LitElement implements LovelaceCard { @@ -86,10 +87,14 @@ export class HuiPictureCard extends LitElement implements LovelaceCard { hasHold: hasAction(this._config!.hold_action), hasDoubleClick: hasAction(this._config!.double_tap_action), })} - tabindex="0" + tabindex=${ifDefined( + hasAction(this._config.tap_action) ? "0" : undefined + )} class="${classMap({ clickable: Boolean( - this._config.tap_action || this._config.hold_action + this._config.tap_action || + this._config.hold_action || + this._config.double_tap_action ), })}" >