nuxt / nuxt

The Intuitive Vue Framework.

Home Page:https://nuxt.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scrollBehavior is not what I expected

mofiter opened this issue · comments

Versions

  • nuxt: v2.15.8
  • node: v14.18.1

Reproduction

scrollBehavior is not what I expected, here is the codesanbox link

Additional Details
I created app/router.scrollBehavior.js file to define a custom behavior

Steps to reproduce

  1. open the pages/index.vue, scroll it down, the picture below is an example:
    image
  2. click item, it will enter pages/product/_id.vue, the picture below is an example:
    image
  3. click browser's back button, back to pages/index.vue.

What is Expected?

  1. from pages/index.vue to pages/product/_id.vue, I don't expect it scroll to top in pages/index.vue at first;
  2. from pages/product/_id.vue back to pages/index.vue, I expect it scroll to savedPosition.

What is actually happening?

  1. from pages/index.vue to pages/product/_id.vue, it scroll to top in pages/index.vue at first;
  2. from pages/product/_id.vue back to pages/index.vue, it scroll to top.
  3. the gif below is an example:

iShot2021-11-09 15 23 16

commented

Thanks for your contribution to Nuxt!
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:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.