summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/eighty-olives-destroy.md5
-rw-r--r--packages/astro/src/transitions/router.ts2
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) {