From 5237cc72b7de6c98ec6958ce5d501432799ec9f0 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 7 Apr 2025 13:18:05 +0200 Subject: [PATCH] Restore default hold action for some cards (#24947) --- .../lovelace/cards/hui-picture-glance-card.ts | 1 + .../elements/hui-icon-element-editor.ts | 20 +++++++++++++------ .../elements/hui-image-element-editor.ts | 20 +++++++++++++------ .../hui-state-badge-element-editor.ts | 20 +++++++++++++------ .../elements/hui-state-icon-element-editor.ts | 20 +++++++++++++------ .../hui-state-label-element-editor.ts | 20 +++++++++++++------ .../hui-picture-glance-card-editor.ts | 20 +++++++++++++------ .../lovelace/elements/hui-icon-element.ts | 6 +++++- .../lovelace/elements/hui-image-element.ts | 6 +++++- .../elements/hui-state-badge-element.ts | 6 +++++- .../elements/hui-state-icon-element.ts | 1 + .../elements/hui-state-label-element.ts | 6 +++++- 12 files changed, 106 insertions(+), 40 deletions(-) diff --git a/src/panels/lovelace/cards/hui-picture-glance-card.ts b/src/panels/lovelace/cards/hui-picture-glance-card.ts index fb1f8311cd..ecd421cf41 100644 --- a/src/panels/lovelace/cards/hui-picture-glance-card.ts +++ b/src/panels/lovelace/cards/hui-picture-glance-card.ts @@ -106,6 +106,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard { this._config = { tap_action: { action: "more-info" }, + hold_action: { action: "more-info" }, ...config, }; } diff --git a/src/panels/lovelace/editor/config-elements/elements/hui-icon-element-editor.ts b/src/panels/lovelace/editor/config-elements/elements/hui-icon-element-editor.ts index f10da54dbc..350327a747 100644 --- a/src/panels/lovelace/editor/config-elements/elements/hui-icon-element-editor.ts +++ b/src/panels/lovelace/editor/config-elements/elements/hui-icon-element-editor.ts @@ -39,20 +39,28 @@ const SCHEMA = [ }, }, }, + { + name: "hold_action", + selector: { + ui_action: { + default_action: "more-info", + }, + }, + }, { name: "", type: "optional_actions", flatten: true, - schema: (["hold_action", "double_tap_action"] as const).map( - (action) => ({ - name: action, + schema: [ + { + name: "double_tap_action", selector: { ui_action: { - default_action: "none" as const, + default_action: "none", }, }, - }) - ), + }, + ], }, ], }, diff --git a/src/panels/lovelace/editor/config-elements/elements/hui-image-element-editor.ts b/src/panels/lovelace/editor/config-elements/elements/hui-image-element-editor.ts index dd7c86a9b4..092f26456e 100644 --- a/src/panels/lovelace/editor/config-elements/elements/hui-image-element-editor.ts +++ b/src/panels/lovelace/editor/config-elements/elements/hui-image-element-editor.ts @@ -44,20 +44,28 @@ const SCHEMA = [ }, }, }, + { + name: "hold_action", + selector: { + ui_action: { + default_action: "more-info", + }, + }, + }, { name: "", type: "optional_actions", flatten: true, - schema: (["hold_action", "double_tap_action"] as const).map( - (action) => ({ - name: action, + schema: [ + { + name: "double_tap_action", selector: { ui_action: { - default_action: "none" as const, + default_action: "none", }, }, - }) - ), + }, + ], }, ], }, diff --git a/src/panels/lovelace/editor/config-elements/elements/hui-state-badge-element-editor.ts b/src/panels/lovelace/editor/config-elements/elements/hui-state-badge-element-editor.ts index aab46a1025..5e012c7a9e 100644 --- a/src/panels/lovelace/editor/config-elements/elements/hui-state-badge-element-editor.ts +++ b/src/panels/lovelace/editor/config-elements/elements/hui-state-badge-element-editor.ts @@ -37,20 +37,28 @@ const SCHEMA = [ }, }, }, + { + name: "hold_action", + selector: { + ui_action: { + default_action: "more-info", + }, + }, + }, { name: "", type: "optional_actions", flatten: true, - schema: (["hold_action", "double_tap_action"] as const).map( - (action) => ({ - name: action, + schema: [ + { + name: "double_tap_action", selector: { ui_action: { - default_action: "none" as const, + default_action: "none", }, }, - }) - ), + }, + ], }, ], }, diff --git a/src/panels/lovelace/editor/config-elements/elements/hui-state-icon-element-editor.ts b/src/panels/lovelace/editor/config-elements/elements/hui-state-icon-element-editor.ts index 333d220b68..217d8edac6 100644 --- a/src/panels/lovelace/editor/config-elements/elements/hui-state-icon-element-editor.ts +++ b/src/panels/lovelace/editor/config-elements/elements/hui-state-icon-element-editor.ts @@ -49,20 +49,28 @@ const SCHEMA = [ }, }, }, + { + name: "hold_action", + selector: { + ui_action: { + default_action: "more-info", + }, + }, + }, { name: "", type: "optional_actions", flatten: true, - schema: (["hold_action", "double_tap_action"] as const).map( - (action) => ({ - name: action, + schema: [ + { + name: "double_tap_action", selector: { ui_action: { - default_action: "none" as const, + default_action: "none", }, }, - }) - ), + }, + ], }, ], }, diff --git a/src/panels/lovelace/editor/config-elements/elements/hui-state-label-element-editor.ts b/src/panels/lovelace/editor/config-elements/elements/hui-state-label-element-editor.ts index 6589e426e0..561419dd9e 100644 --- a/src/panels/lovelace/editor/config-elements/elements/hui-state-label-element-editor.ts +++ b/src/panels/lovelace/editor/config-elements/elements/hui-state-label-element-editor.ts @@ -49,20 +49,28 @@ const SCHEMA = [ }, }, }, + { + name: "hold_action", + selector: { + ui_action: { + default_action: "more-info", + }, + }, + }, { name: "", type: "optional_actions", flatten: true, - schema: (["hold_action", "double_tap_action"] as const).map( - (action) => ({ - name: action, + schema: [ + { + name: "double_tap_action", selector: { ui_action: { - default_action: "none" as const, + default_action: "none", }, }, - }) - ), + }, + ], }, ], }, diff --git a/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts index ff52bae510..763380265d 100644 --- a/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts @@ -71,20 +71,28 @@ const SCHEMA = [ }, }, }, + { + name: "hold_action", + selector: { + ui_action: { + default_action: "more-info", + }, + }, + }, { name: "", type: "optional_actions", flatten: true, - schema: (["hold_action", "double_tap_action"] as const).map( - (action) => ({ - name: action, + schema: [ + { + name: "double_tap_action", selector: { ui_action: { - default_action: "none" as const, + default_action: "none", }, }, - }) - ), + }, + ], }, ], }, diff --git a/src/panels/lovelace/elements/hui-icon-element.ts b/src/panels/lovelace/elements/hui-icon-element.ts index 1d54b0c05a..7d31a9f441 100644 --- a/src/panels/lovelace/elements/hui-icon-element.ts +++ b/src/panels/lovelace/elements/hui-icon-element.ts @@ -31,7 +31,11 @@ export class HuiIconElement extends LitElement implements LovelaceElement { throw Error("Icon required"); } - this._config = { tap_action: { action: "more-info" }, ...config }; + this._config = { + tap_action: { action: "more-info" }, + hold_action: { action: "more-info" }, + ...config, + }; } protected render() { diff --git a/src/panels/lovelace/elements/hui-image-element.ts b/src/panels/lovelace/elements/hui-image-element.ts index ff94f9b68e..e59d5e20bd 100644 --- a/src/panels/lovelace/elements/hui-image-element.ts +++ b/src/panels/lovelace/elements/hui-image-element.ts @@ -29,7 +29,11 @@ export class HuiImageElement extends LitElement implements LovelaceElement { throw Error("Invalid configuration"); } - this._config = { tap_action: { action: "more-info" }, ...config }; + this._config = { + tap_action: { action: "more-info" }, + hold_action: { action: "more-info" }, + ...config, + }; this.classList.toggle( "clickable", diff --git a/src/panels/lovelace/elements/hui-state-badge-element.ts b/src/panels/lovelace/elements/hui-state-badge-element.ts index 1c08801d90..dcb76ae25a 100644 --- a/src/panels/lovelace/elements/hui-state-badge-element.ts +++ b/src/panels/lovelace/elements/hui-state-badge-element.ts @@ -60,7 +60,11 @@ export class HuiStateBadgeElement throw Error("Entity required"); } - this._config = { tap_action: { action: "more-info" }, ...config }; + this._config = { + tap_action: { action: "more-info" }, + hold_action: { action: "more-info" }, + ...config, + }; } protected shouldUpdate(changedProps: PropertyValues): boolean { diff --git a/src/panels/lovelace/elements/hui-state-icon-element.ts b/src/panels/lovelace/elements/hui-state-icon-element.ts index 6e6a08c995..1d6948642f 100644 --- a/src/panels/lovelace/elements/hui-state-icon-element.ts +++ b/src/panels/lovelace/elements/hui-state-icon-element.ts @@ -60,6 +60,7 @@ export class HuiStateIconElement extends LitElement implements LovelaceElement { this._config = { state_color: true, tap_action: { action: "more-info" }, + hold_action: { action: "more-info" }, ...config, }; } diff --git a/src/panels/lovelace/elements/hui-state-label-element.ts b/src/panels/lovelace/elements/hui-state-label-element.ts index cc64ae8ea8..08a1f16b4d 100644 --- a/src/panels/lovelace/elements/hui-state-label-element.ts +++ b/src/panels/lovelace/elements/hui-state-label-element.ts @@ -56,7 +56,11 @@ class HuiStateLabelElement extends LitElement implements LovelaceElement { throw Error("Entity required"); } - this._config = { tap_action: { action: "more-info" }, ...config }; + this._config = { + tap_action: { action: "more-info" }, + hold_action: { action: "more-info" }, + ...config, + }; } protected shouldUpdate(changedProps: PropertyValues): boolean {