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

fix(#17820): prevent event propagation to browser history when clicki… #22523

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 13 additions & 1 deletion src/panels/lovelace/components/hui-generic-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class HuiGenericEntityRow extends LitElement {
class="text-content value ${classMap({
pointer,
})}"
@action=${this._handleAction}
@action=${this._handleValueAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this.config!.hold_action),
hasDoubleClick: hasAction(this.config!.double_tap_action),
Expand All @@ -193,6 +193,18 @@ export class HuiGenericEntityRow extends LitElement {
handleAction(this, this.hass!, this.config!, ev.detail.action!);
}

// To stop unwanted event propagation, only handle the action
// if it originated from the value div or its direct state child
private _handleValueAction(ev: ActionHandlerEvent) {
ev.stopPropagation();
if (
ev.target === ev.currentTarget ||
ev.target === this.shadowRoot?.querySelector(".state")
) {
this._handleAction(ev);
}
}

static get styles(): CSSResultGroup {
return css`
:host {
Expand Down
Loading