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 2 commits
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
27 changes: 23 additions & 4 deletions src/panels/lovelace/cards/hui-tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,40 @@ export class HuiTileCard extends LitElement implements LovelaceCard {

@eventOptions({ passive: true })
private handleRippleActivate(evt?: Event) {
if (!this.hasCardAction) return;
this._rippleHandlers.startPress(evt);
}

private handleRippleDeactivate() {
if (!this.hasCardAction) return;
this._rippleHandlers.endPress();
}

private handleRippleMouseEnter() {
if (!this.hasCardAction) return;
this._rippleHandlers.startHover();
}

private handleRippleMouseLeave() {
if (!this.hasCardAction) return;
this._rippleHandlers.endHover();
}

get hasCardAction() {
return (
!this._config?.tap_action ||
hasAction(this._config?.tap_action) ||
hasAction(this._config?.hold_action) ||
hasAction(this._config?.double_tap_action)
);
}

get hasIconAction() {
return (
!this._config?.icon_tap_action || hasAction(this._config?.icon_tap_action)
);
}

protected render() {
if (!this._config || !this.hass) {
return nothing;
Expand Down Expand Up @@ -368,8 +387,8 @@ 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=${this.hasCardAction ? "button" : ""}
tabindex=${this.hasCardAction ? "0" : undefined}
karwosts marked this conversation as resolved.
Show resolved Hide resolved
aria-labelledby="info"
@mousedown=${this.handleRippleActivate}
@mouseup=${this.handleRippleDeactivate}
Expand All @@ -386,8 +405,8 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
<div class="content ${classMap(contentClasses)}">
<div
class="icon-container"
role="button"
tabindex="0"
role=${this.hasIconAction ? "button" : ""}
tabindex=${this.hasIconAction ? "0" : undefined}
karwosts marked this conversation as resolved.
Show resolved Hide resolved
@action=${this._handleIconAction}
.actionHandler=${actionHandler()}
>
Expand Down
Loading