Skip to content

Commit

Permalink
reset history title after push/replace but prior to assignment to loc…
Browse files Browse the repository at this point in the history
…ation (#10605)

* reset history title after push/replace but prior to assignment to location

* add changeset
  • Loading branch information
martrapp committed Mar 29, 2024
1 parent e648c55 commit a16a829
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eighty-olives-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes an issue with outdated page titles in browser history when using text fragments in view transition navigation.
2 changes: 1 addition & 1 deletion packages/astro/src/transitions/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const moveToLocation = (
);
}
}
document.title = targetPageTitle;
// now we are on the new page for non-history navigations!
// (with history navigation page change happens before popstate is fired)
originalLocation = to;
Expand Down Expand Up @@ -212,7 +213,6 @@ const moveToLocation = (
}
history.scrollRestoration = 'manual';
}
document.title = targetPageTitle;
};

function preloadStyleLinks(newDocument: Document) {
Expand Down

0 comments on commit a16a829

Please sign in to comment.