nuxt: scrollToTop not working for `_slug` style routes
Version
Reproduction link
https://github.com/shipshapecode/website-nuxt
Steps to reproduce
If you run yarn dev and navigate to the blog route, then click a blog post, then scroll to the bottom, and click one of the next/previous links, you will notice it will drop you at the same scroll position as the post you navigated from, rather than resetting the scroll position.
You can also see this reproduced, without needing to pull down code if you go to https://shipshape.io/blog/ad-hoc-relationships-with-ember-data/ and click the next/previous links at the bottom.
What is expected ?
scrollToTop should be respected and the scroll position should be reset, when following links, and maintained when using the back button.
What is actually happening?
The scroll is not reset, and you are put at the same scroll position as the previous post.
<div align="right">This bug report is available on Nuxt community (#c8772)</div>About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 34 (1 by maintainers)
This is still an issue.
Today while i was working on a nuxt ts project, i was amazed with the behavior of a css element.
which is overflow-x: hidden on html and body tag.
As a result nuxt js scrollToTop behavior was not working.
To fix the issue i had to put another div on layouts file with width:100vw and overflow-x: hidden
Hi brother add this code at root of
nuxt.config.jsfile to fix scrollwhat happened ? I have same issue , I could not find any closed issue for this problem
Thanks for your contribution to Nuxt.js! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:
Issues that are labeled as
šPendingwill not be automatically marked as stale.Why is this issue closed, itās clearly not resolved ?
Still having the same issue š¦ Iām not doing anything fancy either. Just basic <nuxt-link to="/blah"> and even when I set scrollToTop on any route it doesnāt do anything.
@pimlie
<nuxt-link>{ x: 0, y: 0 }@pimlie Sorry, itās look like iām misunderstood how
<transition>works. If<nuxt />is wrapped into<transitional>,triggerScrollwill not called. Example: https://codesandbox.io/embed/example-custom-routes-x7lvs Take a look atlayouts/default.vueAny bugfix pls?
@siblanco
setTimeoutdoesnāt related to page load, so in case of long page load, it will be scrolled earlier.I use
nextTicknow, but it have side effects:@rwwagner90 No, pending means it is an āacknowledgeā/ārepro-ableā bug.
Either way, this is a bug in Nuxt, and should be addressed, rather than needing a workaround.