fix: a new view opens at its top instead of the last view's scroll offset
CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / frontend-build (push) Successful in 21s
CI and images / backend-lint-and-test (push) Successful in 31s
CI and images / integration (push) Successful in 2m17s
CI and images / sign-extension (push) Successful in 3s
CI and images / build-agent (push) Successful in 6s
CI and images / build-web (push) Successful in 1m39s
CI and images / smoke-web (push) Successful in 55s
CI and images / promote (push) Skipped
CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / frontend-build (push) Successful in 21s
CI and images / backend-lint-and-test (push) Successful in 31s
CI and images / integration (push) Successful in 2m17s
CI and images / sign-extension (push) Successful in 3s
CI and images / build-agent (push) Successful in 6s
CI and images / build-web (push) Successful in 1m39s
CI and images / smoke-web (push) Successful in 55s
CI and images / promote (push) Skipped
The router had no scrollBehavior, so Settings entered from a scrolled feed opened scrolled too, its heading and tab strip under the nav. Back/forward restores the saved position, and a new query on the same view keeps its place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
This commit is contained in:
+17
-1
@@ -94,9 +94,25 @@ const routes = [
|
||||
const history =
|
||||
typeof window !== 'undefined' ? createWebHistory() : createMemoryHistory()
|
||||
|
||||
// Where the window lands after a navigation. Without this the router keeps the
|
||||
// window's scroll offset, so a view entered from halfway down another one opened
|
||||
// halfway down itself, its heading and tab strip under the nav (operator-flagged
|
||||
// 2026-09-24, Settings entered from a scrolled feed).
|
||||
// - back/forward returns to where that entry was left;
|
||||
// - the SAME view with a new query (a gallery filter, a Browse or
|
||||
// Subscriptions tab) keeps its place — that is not a new page;
|
||||
// - a new view opens at its top.
|
||||
export function scrollBehavior(to, from, savedPosition) {
|
||||
if (savedPosition) return savedPosition
|
||||
if (from.matched.length && to.path === from.path) return false
|
||||
if (to.hash) return { el: to.hash }
|
||||
return { top: 0 }
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history,
|
||||
routes
|
||||
routes,
|
||||
scrollBehavior
|
||||
})
|
||||
|
||||
const DEFAULT_TITLE = 'FabledCurator'
|
||||
|
||||
Reference in New Issue
Block a user