Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 38x 38x 578x 38x 578x 39x | import type { RouterScrollBehavior } from "vue-router";
// Manual fix for https://github.com/nuxt/nuxt/issues/24070
export default defineNuxtPlugin(({ $router }) => {
// eslint-disable-next-line sonarjs/deprecation -- its replacement is still in vue-router/experimental
let nuxtDefault = $router.options.scrollBehavior;
const scrollBehavior: RouterScrollBehavior = (to, from, savedPosition) =>
to.path === from.path && !to.hash && to.query.page !== from.query.page
? (savedPosition ?? { top: 0 })
: nuxtDefault?.(to, from, savedPosition);
// Nuxt reassigns this after the first navigation, so assignments are caught rather than wrapped once
Object.defineProperty($router.options, "scrollBehavior", {
configurable: true,
enumerable: true,
get: () => scrollBehavior,
set: (value?: RouterScrollBehavior) => {
nuxtDefault = value;
},
});
});
|