Skip to content

Commit 0341fb7

Browse files
authored
Fix scrolling on router.refresh (vercel#42583)
Accidentally returned `true` in this case whereas all others are `false`. Fixes vercel#41745 (comment). <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change that you're making: --> ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 8dea5b0 commit 0341fb7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/next/client/components/reducer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,8 @@ function clientReducer(
11121112
tree: tree,
11131113
}
11141114
}
1115+
// TODO-APP: Add test for not scrolling to nearest layout when calling refresh.
1116+
// TODO-APP: Add test for startTransition(() => {router.push('/'); router.refresh();}), that case should scroll.
11151117
case ACTION_REFRESH: {
11161118
const { cache, mutable } = action
11171119
const href = state.canonicalUrl
@@ -1151,7 +1153,7 @@ function clientReducer(
11511153
pushRef: state.pushRef,
11521154
// Apply focus and scroll.
11531155
// TODO-APP: might need to disable this for Fast Refresh.
1154-
focusAndScrollRef: { apply: true },
1156+
focusAndScrollRef: { apply: false },
11551157
cache: cache,
11561158
prefetchCache: state.prefetchCache,
11571159
tree: mutable.patchedTree,

0 commit comments

Comments
 (0)