Skip to content

Commit dfc1fb3

Browse files
committed
fix(scroll): avoid reusing scroll position
1 parent 07100fc commit dfc1fb3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/router.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ export function createRouter(options: RouterOptions): Router {
652652
pendingLocation = toLocation
653653
const from = currentRoute.value
654654

655+
// TODO: should be moved to web history?
655656
if (isBrowser) {
656657
saveScrollPosition(
657658
getScrollKey(from.fullPath, info.delta),

src/scrollBehavior.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ export function saveScrollPosition(
123123
}
124124

125125
export function getSavedScrollPosition(key: string) {
126-
return scrollPositions.get(key)
126+
const scroll = scrollPositions.get(key)
127+
// consume it so it's not used again
128+
scrollPositions.delete(key)
129+
return scroll
127130
}
128131

129132
// TODO: RFC about how to save scroll position

0 commit comments

Comments
 (0)