diff options
author | 2024-03-29 17:02:30 +0100 | |
---|---|---|
committer | 2024-03-29 16:02:30 +0000 | |
commit | a16a829f4e25ad5c9a1b4557ec089fc8ab53320f (patch) | |
tree | a3bee6f9cd2251af58b8be9258db272787f66712 | |
parent | e648c5575a8774af739231cfa9fc27a32086aa5f (diff) | |
download | astro-a16a829f4e25ad5c9a1b4557ec089fc8ab53320f.tar.gz astro-a16a829f4e25ad5c9a1b4557ec089fc8ab53320f.tar.zst astro-a16a829f4e25ad5c9a1b4557ec089fc8ab53320f.zip |
reset history title after push/replace but prior to assignment to location (#10605)
* reset history title after push/replace but prior to assignment to location
* add changeset
-rw-r--r-- | .changeset/eighty-olives-destroy.md | 5 | ||||
-rw-r--r-- | packages/astro/src/transitions/router.ts | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/eighty-olives-destroy.md b/.changeset/eighty-olives-destroy.md new file mode 100644 index 000000000..be8ae9808 --- /dev/null +++ b/.changeset/eighty-olives-destroy.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an issue with outdated page titles in browser history when using text fragments in view transition navigation. diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index c9dd2497e..b1d30558b 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -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; @@ -212,7 +213,6 @@ const moveToLocation = ( } history.scrollRestoration = 'manual'; } - document.title = targetPageTitle; }; function preloadStyleLinks(newDocument: Document) { |