summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Martin Trapp <94928215+martrapp@users.noreply.github.com> 2023-08-02 19:07:30 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-02 13:07:30 -0400
commitc264be3497db4aa8b3bcce0d2f79a26e35b8e91e (patch)
tree2aa8fbfbf86e5a52434a68e26df7d68629f876ce
parent00cb28f4964a60bc609770108d491acc277997b9 (diff)
downloadastro-c264be3497db4aa8b3bcce0d2f79a26e35b8e91e.tar.gz
astro-c264be3497db4aa8b3bcce0d2f79a26e35b8e91e.tar.zst
astro-c264be3497db4aa8b3bcce0d2f79a26e35b8e91e.zip
Fix scroll position in view transition (#7882) (#7911)
-rw-r--r--.changeset/witty-bikes-relate.md5
-rw-r--r--packages/astro/components/ViewTransitions.astro2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/witty-bikes-relate.md b/.changeset/witty-bikes-relate.md
new file mode 100644
index 000000000..0222d209b
--- /dev/null
+++ b/.changeset/witty-bikes-relate.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+fix for #7882 by setting state in page navigation (view transitions)
diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro
index ac40608d3..d96a85181 100644
--- a/packages/astro/components/ViewTransitions.astro
+++ b/packages/astro/components/ViewTransitions.astro
@@ -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 });