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

viewTransitions: clicking a link doesn't reset scrollY to 0 #7882

Closed
1 task done
martrapp opened this issue Jul 31, 2023 · 0 comments · Fixed by #7911
Closed
1 task done

viewTransitions: clicking a link doesn't reset scrollY to 0 #7882

martrapp opened this issue Jul 31, 2023 · 0 comments · Fixed by #7911
Labels
feat: view transitions Related to the View Transitions feature (scope)

Comments

@martrapp
Copy link
Member

martrapp commented Jul 31, 2023

What version of astro are you using?

2.9.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Chrome

Describe the Bug

For viewTransitions:

  • The current page is larger than the viewport and was scrolled to the bottom.
  • Navigation to another page shows the middle/bottom part of that page, not the beginning.

What's the expected result?

Regardless of the scroll position of the referring page, the new page is displayed from the beginning

Possible solution:
initialize scrollY in the click handler when navigating: navigate('forward', link.href, { scrollY: 0 });

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-fmqrqm?file=src%2Fpages%2Fother-page.astro

Participation

  • I am willing to submit a pull request for this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: view transitions Related to the View Transitions feature (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants