diff --git a/src/action-handler.ts b/src/action-handler.ts index 87066ae..f2206dc 100644 --- a/src/action-handler.ts +++ b/src/action-handler.ts @@ -23,6 +23,7 @@ export interface ActionHandlerOptions { hasHold?: boolean; hasDoubleClick?: boolean; disabled?: boolean; + stopPropagation?: boolean; repeat?: number; repeatLimit?: number; } @@ -138,6 +139,9 @@ class ActionHandler extends HTMLElement implements ActionHandler { } element.actionHandler.start = (ev: Event) => { + if (options.stopPropagation) { + ev.stopPropagation(); + } this.cancelled = false; let x; let y; @@ -171,6 +175,9 @@ class ActionHandler extends HTMLElement implements ActionHandler { }; element.actionHandler.end = (ev: Event) => { + if (options.stopPropagation) { + ev.stopPropagation(); + } // Don't respond when moved or scrolled while touch if (['touchend', 'touchcancel'].includes(ev.type) && this.cancelled) { if (this.isRepeating && this.repeatTimeout) { diff --git a/src/button-card.ts b/src/button-card.ts index c2e0794..2dd5b36 100644 --- a/src/button-card.ts +++ b/src/button-card.ts @@ -998,6 +998,7 @@ class ButtonCard extends LitElement { .actionHandler=${actionHandler({ hasDoubleClick: this._config!.double_tap_action!.action !== 'none', hasHold: this._config!.hold_action!.action !== 'none', + stopPropagation: this._config!.stop_propagation, repeat: this._config!.hold_action!.repeat, repeatLimit: this._config!.hold_action!.repeat_limit, })} diff --git a/src/types/types.ts b/src/types/types.ts index f18e5b7..a820a5b 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -18,6 +18,7 @@ export interface ButtonCardConfig { tap_action?: ActionConfig; hold_action?: ActionConfig; double_tap_action?: ActionConfig; + stop_propagation?: boolean; show_name?: boolean; show_state?: boolean; show_icon?: boolean; @@ -58,6 +59,7 @@ export interface ExternalButtonCardConfig { tap_action?: ActionConfig; hold_action?: ActionConfig; double_tap_action?: ActionConfig; + stop_propagation?: boolean; show_name?: boolean; show_state?: boolean; show_icon?: boolean;