Skip to content

Commit

Permalink
Fix scroll position in view transition (#7882) (#7911)
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp authored Aug 2, 2023
1 parent 00cb28f commit c264be3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/witty-bikes-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

fix for #7882 by setting state in page navigation (view transitions)
2 changes: 1 addition & 1 deletion packages/astro/components/ViewTransitions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const { fallback = 'animate' } = Astro.props as Props;
transitionEnabledOnThisPage()
) {
ev.preventDefault();
navigate('forward', link.href);
navigate('forward', link.href, { index:currentHistoryIndex, scrollY:0 });
currentHistoryIndex++;
const newState: State = { index: currentHistoryIndex, scrollY };
persistState({ index: currentHistoryIndex - 1, scrollY });
Expand Down

0 comments on commit c264be3

Please sign in to comment.