From a17056fb17f187d0afb6683b3b7741d945f7e85c Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Tue, 11 Aug 2026 14:38:42 +0200 Subject: [PATCH] =?UTF-8?q?Hotfix=20for=20smooth=20scroll=20not=20working?= =?UTF-8?q?=20on=20anchors=20=E2=80=94=20https://github.com/hotwired/turbo?= =?UTF-8?q?/issues/1255?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment-details/payment-details.css | 1 + src/front/index.ts | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/back/jdd-components/payment-details/payment-details.css b/src/back/jdd-components/payment-details/payment-details.css index d8afbf1..377d8b7 100644 --- a/src/back/jdd-components/payment-details/payment-details.css +++ b/src/back/jdd-components/payment-details/payment-details.css @@ -42,6 +42,7 @@ background: none; border: none; cursor: pointer; + svg { height: 16px; width: 16px; diff --git a/src/front/index.ts b/src/front/index.ts index 16ce00b..020b080 100644 --- a/src/front/index.ts +++ b/src/front/index.ts @@ -31,3 +31,33 @@ export * from "./controllers.js"; shouldPreserveScroll = false; }); })(); + +/* fix for https://github.com/hotwired/turbo/issues/1255 */ +(() => { + const markHashLinks = (root: ParentNode): void => { + root.querySelectorAll('a[href^="#"]').forEach((link) => { + link.dataset.turbo = "false"; + }); + }; + + markHashLinks(document); + + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + mutation.addedNodes.forEach((node) => { + if (!(node instanceof Element)) return; + + if (node instanceof HTMLAnchorElement && node.matches('a[href^="#"]')) { + node.dataset.turbo = "false"; + } + + markHashLinks(node); + }); + }); + }); + + observer.observe(document.documentElement, { + childList: true, + subtree: true, + }); +})();