From a9e5980fea72cfb0320736700b2430a55310539b Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sun, 21 Dec 2025 16:11:00 +0200 Subject: [PATCH] Add closestParent --- frontend/src/ts/pages/account.ts | 2 +- frontend/src/ts/utils/dom.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/ts/pages/account.ts b/frontend/src/ts/pages/account.ts index d68b16dbc..f57c3ade6 100644 --- a/frontend/src/ts/pages/account.ts +++ b/frontend/src/ts/pages/account.ts @@ -1092,7 +1092,7 @@ qs(".pageAccount")?.onChild( async (event) => { const target = new ElementWithUtils(event.childTarget as HTMLElement); const resultId: string = target - .closest("tr") + .closestParent("tr") ?.getAttribute("data-id") as string; if (target.hasClass("loading")) return; if (target.hasClass("disabled")) return; diff --git a/frontend/src/ts/utils/dom.ts b/frontend/src/ts/utils/dom.ts index e6f3c8592..9b0d56263 100644 --- a/frontend/src/ts/utils/dom.ts +++ b/frontend/src/ts/utils/dom.ts @@ -553,12 +553,14 @@ export class ElementWithUtils { } /** - * Get the first element matching a selector, starting from this.native and going - up through its parents + * Get the first parent that matches a selector */ - closest(selector: string): ElementWithUtils | null { - const el = this.native.closest(selector) as HTMLElement; - return el !== null ? new ElementWithUtils(el) : null; + + closestParent(selector: string): ElementWithUtils | null { + const closestParent = this.native.parentElement?.closest( + selector, + ) as HTMLElement; + return closestParent !== null ? new ElementWithUtils(closestParent) : null; } /**