Fix scroll position in view transition (#7882) (#7911)

This commit is contained in:
Martin Trapp 2023-08-02 19:07:30 +02:00 committed by GitHub
parent 00cb28f496
commit c264be3497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
fix for #7882 by setting state in page navigation (view transitions)

View file

@ -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 });