diff options
| author | kj_sh604 | 2026-03-12 23:34:14 -0400 |
|---|---|---|
| committer | kj_sh604 | 2026-03-12 23:34:14 -0400 |
| commit | a4fcf876431d729feaa214f02adb131720fec946 (patch) | |
| tree | 0ac63428b1e66683f735df7f89ba423c1b68a2fd | |
| parent | eef8961b63c3d0940ad1ee80040cb140f9ac5973 (diff) | |
refactor: workaround for htmx quirk
| -rw-r--r-- | src/static/main.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/static/main.js b/src/static/main.js index 68d36ad..0f77b1e 100644 --- a/src/static/main.js +++ b/src/static/main.js @@ -38,6 +38,21 @@ document.body.addEventListener("htmx:afterRequest", (event) => { } }); +document.body.addEventListener("htmx:afterSwap", (event) => { + const target = event.detail?.target; + const requestElt = event.detail?.requestConfig?.elt; + + if (!(target instanceof HTMLElement) || target.id !== "result") { + return; + } + + if (!(requestElt instanceof HTMLElement) || requestElt.id !== "convert-form") { + return; + } + + target.scrollIntoView({ behavior: "smooth", block: "start" }); +}); + if (mdFileInput) { mdFileInput.addEventListener("change", () => { const file = mdFileInput.files?.[0]; |
