From b3323c5d00da3f3ec31be569037684249eb5cf7d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 6 Feb 2023 11:37:40 +0100 Subject: [PATCH] web/elements: fix table selection handler firing when click isn't for tr Signed-off-by: Jens Langhammer --- web/src/elements/table/Table.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/src/elements/table/Table.ts b/web/src/elements/table/Table.ts index f20563f47..07c633976 100644 --- a/web/src/elements/table/Table.ts +++ b/web/src/elements/table/Table.ts @@ -292,10 +292,17 @@ export abstract class Table extends AKElement { private renderRowGroup(items: T[]): TemplateResult[] { return items.map((item) => { - const itemSelectHandler = (ev?: InputEvent) => { + const itemSelectHandler = (ev?: InputEvent | PointerEvent) => { let checked = false; if (ev) { - checked = (ev.target as HTMLInputElement).checked; + // Only register click events on a table row + if (ev instanceof PointerEvent) { + if ((ev.target as HTMLInputElement).tagName.toLowerCase() != "tr") { + return; + } + } else if (ev instanceof InputEvent) { + checked = (ev.target as HTMLInputElement).checked; + } } else { // If we have no event, toggle the state checked = this.selectedElements.indexOf(item) === -1; @@ -332,9 +339,7 @@ export abstract class Table extends AKElement { { - itemSelectHandler(); - }} + @click=${itemSelectHandler} > ${this.checkbox ? html`