if (savedPosition) {
return savedPosition
} else {
- return { x: 0, y: 0 }
+ // TODO: check if parent in common that works with alias
+ if (to.matched.every((record, i) => from.matched[i] !== record))
+ return { x: 0, y: 0 }
}
+ // leave scroll as it is by not returning anything
+ // https://github.com/Microsoft/TypeScript/issues/18319
+ return false
},
})
type UseLinkOptions = VueUseOptions<LinkProps>
+// TODO: we could allow currentRoute as a prop to expose `isActive` and
+// `isExactActive` behavior should go through an RFC
export function useLink(props: UseLinkOptions) {
const router = inject(routerKey)!
const currentRoute = router.currentRoute
// resolve, reject arguments of Promise constructor
type OnReadyCallback = [() => void, (reason?: any) => void]
+type Awaitable<T> = T | Promise<T>
+
export interface ScrollBehavior {
(
to: RouteLocationNormalized,
from: RouteLocationNormalizedLoaded,
savedPosition: ScrollToPosition | null
): // TODO: implement false nad refactor promise based type
- | ScrollPosition
- | Promise<ScrollPosition | false | undefined>
- | false
- | undefined
+ Awaitable<ScrollPosition | false | void>
}
export interface RouterOptions {