mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fix pointer cursor issues (#21587)
* Fix pointer cursor issues * one more
This commit is contained in:
parent
0adee7d189
commit
3ba572ee37
@ -23,7 +23,7 @@ import type { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||
import type { LovelaceCard, LovelaceCardEditor } from "../types";
|
||||
@ -128,24 +128,20 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
||||
|
||||
const name = this._config.name ?? computeStateName(stateObj);
|
||||
|
||||
const hasAnyAction =
|
||||
!this._config.tap_action ||
|
||||
hasAction(this._config.tap_action) ||
|
||||
hasAction(this._config.hold_action) ||
|
||||
hasAction(this._config.double_tap_action);
|
||||
|
||||
// Use `stateObj.state` as value to keep formatting (e.g trailing zeros)
|
||||
// for consistent value display across gauge, entity, entity-row, etc.
|
||||
return html`
|
||||
<ha-card
|
||||
class=${classMap({ action: hasAnyAction })}
|
||||
class=${classMap({ action: hasAnyAction(this._config) })}
|
||||
@action=${this._handleAction}
|
||||
.actionHandler=${actionHandler({
|
||||
hasHold: hasAction(this._config.hold_action),
|
||||
hasDoubleClick: hasAction(this._config.double_tap_action),
|
||||
})}
|
||||
tabindex=${ifDefined(
|
||||
hasAction(this._config.tap_action) ? "0" : undefined
|
||||
!this._config.tap_action || hasAction(this._config.tap_action)
|
||||
? "0"
|
||||
: undefined
|
||||
)}
|
||||
>
|
||||
<ha-gauge
|
||||
|
@ -28,7 +28,7 @@ import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||
import { processConfigEntities } from "../common/process-config-entities";
|
||||
import "../components/hui-timestamp-display";
|
||||
@ -263,15 +263,9 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
||||
|
||||
const name = entityConf.name ?? computeStateName(stateObj);
|
||||
|
||||
const hasAnyAction =
|
||||
!entityConf.tap_action ||
|
||||
hasAction(entityConf.tap_action) ||
|
||||
hasAction(entityConf.hold_action) ||
|
||||
hasAction(entityConf.double_tap_action);
|
||||
|
||||
return html`
|
||||
<div
|
||||
class=${classMap({ entity: true, action: hasAnyAction })}
|
||||
class=${classMap({ entity: true, action: hasAnyAction(entityConf) })}
|
||||
.config=${entityConf}
|
||||
@action=${this._handleAction}
|
||||
.actionHandler=${actionHandler({
|
||||
|
@ -1,5 +1,15 @@
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { ConfigEntity } from "../cards/types";
|
||||
|
||||
export function hasAction(config?: ActionConfig): boolean {
|
||||
return config !== undefined && config.action !== "none";
|
||||
}
|
||||
|
||||
export function hasAnyAction(config: ConfigEntity): boolean {
|
||||
return (
|
||||
!config.tap_action ||
|
||||
hasAction(config.tap_action) ||
|
||||
hasAction(config.hold_action) ||
|
||||
hasAction(config.double_tap_action)
|
||||
);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import { HomeAssistant } from "../../../types";
|
||||
import { EntitiesCardEntityConfig } from "../cards/types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||
import { createEntityNotFoundWarning } from "./hui-warning";
|
||||
|
||||
@customElement("hui-generic-entity-row")
|
||||
@ -60,9 +60,7 @@ export class HuiGenericEntityRow extends LitElement {
|
||||
// By default, we always show a pointer, since if there is no explicit configuration provided,
|
||||
// the frontend always assumes "more-info" in the action handler. We only need to hide the pointer
|
||||
// if the tap action is explicitly set to "none".
|
||||
const pointer = !(
|
||||
this.config.tap_action && this.config.tap_action.action === "none"
|
||||
);
|
||||
const pointer = hasAnyAction(this.config);
|
||||
|
||||
const hasSecondary = this.secondaryText || this.config.secondary_info;
|
||||
const name = this.config.name ?? computeStateName(stateObj);
|
||||
@ -82,7 +80,11 @@ export class HuiGenericEntityRow extends LitElement {
|
||||
hasHold: hasAction(this.config!.hold_action),
|
||||
hasDoubleClick: hasAction(this.config!.double_tap_action),
|
||||
})}
|
||||
tabindex=${ifDefined(pointer ? "0" : undefined)}
|
||||
tabindex=${ifDefined(
|
||||
!this.config.tap_action || hasAction(this.config.tap_action)
|
||||
? "0"
|
||||
: undefined
|
||||
)}
|
||||
></state-badge>
|
||||
${!this.hideName
|
||||
? html`<div
|
||||
|
@ -123,7 +123,6 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
:host {
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
.flex {
|
||||
|
@ -70,9 +70,6 @@ class HuiSceneEntityRow extends LitElement implements LovelaceRow {
|
||||
margin-inline-end: -0.57em;
|
||||
margin-inline-start: initial;
|
||||
}
|
||||
:host {
|
||||
cursor: pointer;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,6 @@ class HuiSimpleEntityRow extends LitElement implements LovelaceRow {
|
||||
div {
|
||||
text-align: right;
|
||||
}
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,6 @@ class HuiUpdateEntityRow extends LitElement implements LovelaceRow {
|
||||
div {
|
||||
text-align: right;
|
||||
}
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import type { HomeAssistant } from "../../../types";
|
||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
import "../components/hui-generic-entity-row";
|
||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||
@ -118,9 +118,7 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
||||
`;
|
||||
}
|
||||
|
||||
const pointer = !(
|
||||
this._config.tap_action && this._config.tap_action.action !== "none"
|
||||
);
|
||||
const pointer = hasAnyAction(this._config);
|
||||
|
||||
const hasSecondary = this._config.secondary_info;
|
||||
const weatherStateIcon = getWeatherStateIcon(stateObj.state, this);
|
||||
@ -138,7 +136,11 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
||||
hasHold: hasAction(this._config!.hold_action),
|
||||
hasDoubleClick: hasAction(this._config!.double_tap_action),
|
||||
})}
|
||||
tabindex=${ifDefined(pointer ? "0" : undefined)}
|
||||
tabindex=${ifDefined(
|
||||
!this._config.tap_action || hasAction(this._config.tap_action)
|
||||
? "0"
|
||||
: undefined
|
||||
)}
|
||||
>
|
||||
${weatherStateIcon ||
|
||||
html`
|
||||
|
Loading…
x
Reference in New Issue
Block a user