Skip to content

Commit 09d134f

Browse files
committed
fix: only stop touch propagation when extending a row
1 parent 194d952 commit 09d134f

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/action-handler.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const isTouch =
2626
export interface CustomActionHandlerOptions extends ActionHandlerOptions {
2727
disabled?: boolean;
2828
repeat?: number;
29+
stopPropagation?: boolean;
2930
}
3031

3132
interface Ripple extends HTMLElement {
@@ -180,7 +181,9 @@ class ActionHandler extends HTMLElement implements IActionHandler {
180181
}
181182

182183
element.actionHandler.start = (ev: Event) => {
183-
ev.stopPropagation();
184+
if (options.stopPropagation) {
185+
ev.stopPropagation();
186+
}
184187
this.cancelled = false;
185188
let x: number;
186189
let y: number;
@@ -208,7 +211,9 @@ class ActionHandler extends HTMLElement implements IActionHandler {
208211
};
209212

210213
element.actionHandler.end = (ev: Event) => {
211-
ev.stopPropagation();
214+
if (options.stopPropagation) {
215+
ev.stopPropagation();
216+
}
212217
// Don't respond when moved or scrolled while touch
213218
if (
214219
ev.type === "touchcancel" ||

src/entity-row.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ createModule("hui-generic-entity-row", function () {
4141
{
4242
type: "custom:paper-buttons-row",
4343
...pbConfig,
44+
is_extended_row: true,
4445
},
4546
true,
4647
);

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export class PaperButtonsRow extends LitElement {
260260
hasHold: hasAction(config.hold_action),
261261
hasDoubleClick: hasAction(config.double_tap_action),
262262
repeat: config.hold_action?.repeat,
263+
stopPropagation: !!this._config?.is_extended_row,
263264
})}"
264265
style="${styleMap(buttonStyles)}"
265266
class="${this._getClass(
@@ -363,7 +364,9 @@ export class PaperButtonsRow extends LitElement {
363364

364365
private _handleAction(ev: ActionHandlerEvent, config: ButtonConfig): void {
365366
if (this.hass && config && ev.detail.action) {
366-
ev.stopPropagation();
367+
if (this._config?.is_extended_row) {
368+
ev.stopPropagation();
369+
}
367370
handleAction(this, this.hass, config, ev.detail.action);
368371
}
369372
}

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export interface PaperButtonRowConfig {
6363
position?: "center" | "right";
6464
hide_badge?: boolean;
6565
hide_state?: boolean;
66+
is_extended_row?: boolean;
6667
}
6768

6869
export interface ExternalButtonConfig
@@ -79,6 +80,7 @@ export interface ExternalPaperButtonRowConfig
7980
extends Omit<PaperButtonRowConfig, "buttons" | "styles"> {
8081
buttons: Array<ExternalButtonType | Array<ExternalButtonType>>;
8182
styles?: Record<string, string | Template>;
83+
is_extended_row?: boolean;
8284
}
8385

8486
export interface FireEventActionConfig extends BaseActionConfig {

0 commit comments

Comments
 (0)