Skip to content

Commit

Permalink
Fix scrolling on router.refresh (#42583)
Browse files Browse the repository at this point in the history
Accidentally returned `true` in this case whereas all others are
`false`.

Fixes
#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)
  • Loading branch information
timneutkens committed Nov 7, 2022
1 parent 8dea5b0 commit 0341fb7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/client/components/reducer.ts
Expand Up @@ -1112,6 +1112,8 @@ function clientReducer(
tree: tree,
}
}
// TODO-APP: Add test for not scrolling to nearest layout when calling refresh.
// TODO-APP: Add test for startTransition(() => {router.push('/'); router.refresh();}), that case should scroll.
case ACTION_REFRESH: {
const { cache, mutable } = action
const href = state.canonicalUrl
Expand Down Expand Up @@ -1151,7 +1153,7 @@ function clientReducer(
pushRef: state.pushRef,
// Apply focus and scroll.
// TODO-APP: might need to disable this for Fast Refresh.
focusAndScrollRef: { apply: true },
focusAndScrollRef: { apply: false },
cache: cache,
prefetchCache: state.prefetchCache,
tree: mutable.patchedTree,
Expand Down

0 comments on commit 0341fb7

Please sign in to comment.