Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tile pointer/ripple/index when it has no action #19137

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions src/panels/lovelace/cards/hui-tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
: undefined;
const badge = computeTileBadge(stateObj, this.hass);

const hasCardAction =
!this._config.tap_action ||
hasAction(this._config.tap_action) ||
hasAction(this._config.hold_action) ||
hasAction(this._config.double_tap_action);

const hasIconAction =
!this._config.icon_tap_action || hasAction(this._config.icon_tap_action);

return html`
<ha-card style=${styleMap(style)} class=${classMap({ active })}>
<div
Expand All @@ -368,16 +377,18 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
hasHold: hasAction(this._config!.hold_action),
hasDoubleClick: hasAction(this._config!.double_tap_action),
})}
role="button"
tabindex="0"
role=${hasCardAction ? "button" : ""}
tabindex=${hasCardAction ? "0" : undefined}
aria-labelledby="info"
@mousedown=${this.handleRippleActivate}
@mouseup=${this.handleRippleDeactivate}
@mouseenter=${this.handleRippleMouseEnter}
@mouseleave=${this.handleRippleMouseLeave}
@touchstart=${this.handleRippleActivate}
@touchend=${this.handleRippleDeactivate}
@touchcancel=${this.handleRippleDeactivate}
@mousedown=${hasCardAction ? this.handleRippleActivate : undefined}
@mouseup=${hasCardAction ? this.handleRippleDeactivate : undefined}
@mouseenter=${hasCardAction ? this.handleRippleMouseEnter : undefined}
@mouseleave=${hasCardAction ? this.handleRippleMouseLeave : undefined}
@touchstart=${hasCardAction ? this.handleRippleActivate : undefined}
@touchend=${hasCardAction ? this.handleRippleDeactivate : undefined}
@touchcancel=${hasCardAction
karwosts marked this conversation as resolved.
Show resolved Hide resolved
? this.handleRippleDeactivate
: undefined}
>
${this._shouldRenderRipple
? html`<mwc-ripple></mwc-ripple>`
Expand All @@ -386,8 +397,8 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
<div class="content ${classMap(contentClasses)}">
<div
class="icon-container"
role="button"
tabindex="0"
role=${hasIconAction ? "button" : ""}
tabindex=${hasIconAction ? "0" : undefined}
@action=${this._handleIconAction}
.actionHandler=${actionHandler()}
>
Expand Down
Loading