From cbd80c17a2c2997386308988208a362a2d0ff279 Mon Sep 17 00:00:00 2001 From: Sli Date: Mon, 7 Sep 2026 17:23:23 +0200 Subject: [PATCH] Fix aria-busy during swap and make it a plugin --- core/static/bundled/base-bundle-index.ts | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/core/static/bundled/base-bundle-index.ts b/core/static/bundled/base-bundle-index.ts index 8556a99e..26693455 100644 --- a/core/static/bundled/base-bundle-index.ts +++ b/core/static/bundled/base-bundle-index.ts @@ -48,19 +48,26 @@ polyfillCountryFlagEmojis(); /** * HTMX */ -document.body.addEventListener( - "htmx:before:request" as keyof HTMLElementEventMap, - (event) => { - (event as CustomEvent).detail.ctx.target.ariaBusy = true; +htmx.registerExtension("aria-busy", { + // biome-ignore lint/style/useNamingConvention: api's name + htmx_before_request: ( + _: HTMLElement, + detail: { ctx: { target: HTMLElement | undefined } }, + ) => { + if (detail.ctx.target !== undefined) { + (detail.ctx.target as HTMLElement).ariaBusy = "true"; + } }, -); - -document.body.addEventListener( - "htmx:before:swap" as keyof HTMLElementEventMap, - (event) => { - (event as CustomEvent).detail.ctx.target.ariaBusy = null; + // biome-ignore lint/style/useNamingConvention: api's name + htmx_after_swap: ( + _: HTMLElement, + detail: { ctx: { target: HTMLElement | undefined } }, + ) => { + if (detail.ctx.target !== undefined) { + (detail.ctx.target as HTMLElement).ariaBusy = null; + } }, -); +}); Object.assign(window, { htmx });