web/elements: fix table selection handler firing when click isn't for tr
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
fd9ce531c9
commit
b3323c5d00
|
@ -292,10 +292,17 @@ export abstract class Table<T> extends AKElement {
|
||||||
|
|
||||||
private renderRowGroup(items: T[]): TemplateResult[] {
|
private renderRowGroup(items: T[]): TemplateResult[] {
|
||||||
return items.map((item) => {
|
return items.map((item) => {
|
||||||
const itemSelectHandler = (ev?: InputEvent) => {
|
const itemSelectHandler = (ev?: InputEvent | PointerEvent) => {
|
||||||
let checked = false;
|
let checked = false;
|
||||||
if (ev) {
|
if (ev) {
|
||||||
|
// 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;
|
checked = (ev.target as HTMLInputElement).checked;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If we have no event, toggle the state
|
// If we have no event, toggle the state
|
||||||
checked = this.selectedElements.indexOf(item) === -1;
|
checked = this.selectedElements.indexOf(item) === -1;
|
||||||
|
@ -332,9 +339,7 @@ export abstract class Table<T> extends AKElement {
|
||||||
<tr
|
<tr
|
||||||
role="row"
|
role="row"
|
||||||
class="${this.checkbox ? "pf-m-hoverable" : ""}"
|
class="${this.checkbox ? "pf-m-hoverable" : ""}"
|
||||||
@click=${() => {
|
@click=${itemSelectHandler}
|
||||||
itemSelectHandler();
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
${this.checkbox
|
${this.checkbox
|
||||||
? html`<td class="pf-c-table__check" role="cell">
|
? html`<td class="pf-c-table__check" role="cell">
|
||||||
|
|
Reference in a new issue