mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
Fix history navigation to hash fragment on Firefox when using view transitions (#9563)
* Fix history navigation to hash fragment on Firefox when using view transitions * Edit changeset * Improve changeset, add co-authors
This commit is contained in:
parent
d854330571
commit
d48ab90fb4
2 changed files with 11 additions and 1 deletions
8
.changeset/breezy-eyes-teach.md
Normal file
8
.changeset/breezy-eyes-teach.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fixes back navigation to fragment links (e.g. `#about`) in Firefox when using view transitions
|
||||
|
||||
Co-authored-by: Florian Lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
|
||||
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
|
|
@ -213,7 +213,9 @@ const moveToLocation = (to: URL, from: URL, options: Options, historyState?: Sta
|
|||
// ... what comes next is a intra-page navigation
|
||||
// that won't reload the page but instead scroll to the fragment
|
||||
history.scrollRestoration = 'auto';
|
||||
location.href = to.href;
|
||||
const savedState = history.state;
|
||||
location.href = to.href; // this kills the history state on Firefox
|
||||
history.state || history.replaceState(savedState, ''); // this restores the history state
|
||||
} else {
|
||||
if (!scrolledToTop) {
|
||||
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
||||
|
|
Loading…
Add table
Reference in a new issue