Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 12 additions & 6 deletions src/button-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,12 @@ class ButtonCard extends LitElement {
<div
id=${key}
@action=${this._stopPropagation}
@click=${this._stopPropagation}
@touchstart=${this._stopPropagation}
@mousedown=${this._stopPropagation}
@mouseup=${this._stopPropagation}
@touchend=${this._stopPropagation}
@touchcancel=${this._stopPropagation}
@click=${this._sendToParent}
@touchstart=${this._sendToParent}
@mousedown=${this._sendToParent}
@mouseup=${this._sendToParent}
@touchend=${this._sendToParent}
@touchcancel=${this._sendToParent}
style=${styleMap(customStyle)}
>
${thing}
Expand Down Expand Up @@ -1525,4 +1525,10 @@ class ButtonCard extends LitElement {
private _stopPropagation(ev: Event): void {
ev.stopPropagation();
}

private _sendToParent(ev: Event): void {
ev.stopPropagation();
const event = new CustomEvent(ev.type, ev);
this.parentElement?.dispatchEvent(event);
}
}
9 changes: 9 additions & 0 deletions test/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,9 @@ views:
entity: switch.skylight
show_icon: false
name: '[[[ return `Main entity: ${entity.entity_id || "unknown entity"}`; ]]]'
label: Tap should toggle
tap_action:
action: toggle
styles:
grid:
- grid-template-areas: '"n" "nested"'
Expand All @@ -1482,7 +1485,13 @@ views:
type: 'custom:button-card'
name: '[[[[ return (entity?.entity_id || "4[ ]: main button entity not known"); ]]]]'
label: '[[[ return `3[ ]: ${(entity?.entity_id || "main button state not known")}`; ]]]'
show_state: true
state_display: Above should show "not known" <br/> below should show ¨switch.skylight".<br/>Tap should not trigger parent button action
show_label: true
show_icon: false
tap_action:
action: more-info
entity: switch.skylight

- type: custom:button-card
entity: switch.skylight
Expand Down