Add hold and double tap actions in hui-entity-heading-badge (#24707)

* feat: Add support for hold and double tap actions in hui-entity-heading-badge

* fix: Add hold_action and double_tap_action to config struct and interactions to allow GUI editor to work for badge interactions

* chore: Remove hold and double_tap from UI editor schema on entity heading badge editor
This commit is contained in:
Clay Benson 2025-03-24 09:19:41 -04:00 committed by GitHub
parent 9f05f4df50
commit e0fbd3cd1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -44,6 +44,8 @@ const entityConfigStruct = object({
show_icon: optional(boolean()),
color: optional(string()),
tap_action: optional(actionConfigStruct),
hold_action: optional(actionConfigStruct),
double_tap_action: optional(actionConfigStruct),
visibility: optional(array(any())),
});

View File

@ -49,6 +49,12 @@ export class HuiEntityHeadingBadge
tap_action: {
action: "none",
},
hold_action: {
action: "none",
},
double_tap_action: {
action: "none",
},
...config,
};
}
@ -58,6 +64,12 @@ export class HuiEntityHeadingBadge
tap_action: {
action: "none",
},
hold_action: {
action: "none",
},
double_tap_action: {
action: "none",
},
...this._config!,
};
handleAction(this, this.hass!, config, ev.detail.action!);
@ -135,7 +147,10 @@ export class HuiEntityHeadingBadge
<ha-heading-badge
.type=${hasAction(config.tap_action) ? "button" : "text"}
@action=${this._handleAction}
.actionHandler=${actionHandler()}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config!.hold_action),
hasDoubleClick: hasAction(this._config!.double_tap_action),
})}
style=${styleMap(style)}
.title=${name}
>