Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating query string with shallow routing scrolls to top since v10.0.0 #21366

Closed
meandillar opened this issue Jan 20, 2021 · 2 comments · Fixed by #21437
Closed

Updating query string with shallow routing scrolls to top since v10.0.0 #21366

meandillar opened this issue Jan 20, 2021 · 2 comments · Fixed by #21437
Milestone

Comments

@meandillar
Copy link

meandillar commented Jan 20, 2021

What version of Next.js are you using?

10.0.5

What version of Node.js are you using?

12.18.3

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

Using the { shallow: true } option with router.push previously prevented the browser from scrolling to the top of the page. I've tested versions 10.0.0, 10.0.1, 10.0.5 & the latest 10.0.6-canary.5 all of which have the bug. When using 9.5.5 and 9.5.6-canary.18 no scrolling happens which is the expected result.

Expected Behavior

No scrolling to top.

To Reproduce

Update a query string using router.push with the shallow option set to true. I'm using the example below for a "See More Results" button.

Using router.push('some-url?page=2', undefined, { shallow: true })

EDIT: Formatting

@meandillar meandillar added the bug Issue was opened via the bug report template. label Jan 20, 2021
@jigsawpieces
Copy link

jigsawpieces commented Jan 20, 2021

It's missing the current docs, but you can prevent this by passing { scroll: false } as the third parameter, e.g. router.push(url, as, { scroll: false }).

See #20606 for details.

@Timer Timer added kind: bug and removed bug Issue was opened via the bug report template. labels Jan 22, 2021
@kodiakhq kodiakhq bot closed this as completed in #21437 Jan 22, 2021
@Timer Timer added this to the iteration 16 milestone Jan 22, 2021
kodiakhq bot pushed a commit that referenced this issue Jan 22, 2021
This ensures that Next.js will not scroll to the top of the page in shallow routing.

Fixes: #21386
Fixes: #21366
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants