From 1adec8936fcd6cb81f50fc41fc2e5b3d2dd1759f Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Thu, 21 May 2026 14:59:01 +0200 Subject: [PATCH] feat: allow skipping scrolling on partial navigation --- packages/fresh/src/runtime/client/partials.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/fresh/src/runtime/client/partials.ts b/packages/fresh/src/runtime/client/partials.ts index 008e23a9592..479d04df829 100644 --- a/packages/fresh/src/runtime/client/partials.ts +++ b/packages/fresh/src/runtime/client/partials.ts @@ -25,6 +25,7 @@ import { parse } from "../../jsonify/parse.ts"; import { INTERNAL_PREFIX, PARTIAL_SEARCH_PARAM } from "../../constants.ts"; export const PARTIAL_ATTR = "f-partial"; +export const PARTIAL_NO_SCROLL_ATTR = "f-dont-scroll"; class NoPartialsError extends Error {} @@ -170,7 +171,9 @@ document.addEventListener("click", async (e) => { await fetchPartials(nextUrl, partialUrl, true); updateLinks(nextUrl); }); - scrollTo({ left: 0, top: 0, behavior: "instant" }); + if (!el.hasAttribute(PARTIAL_NO_SCROLL_ATTR)) { + scrollTo({ left: 0, top: 0, behavior: "instant" }); + } } finally { if (indicator !== undefined) { indicator.value = false;