diff --git a/.changeset/weak-planes-help.md b/.changeset/weak-planes-help.md
new file mode 100644
index 000000000000..4bb69fe7a202
--- /dev/null
+++ b/.changeset/weak-planes-help.md
@@ -0,0 +1,4 @@
+---
+"astro": patch
+---
+Fixes an issue where anchor elements within a custom component could not trigger a view transition.
diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro
index e8e12ce3d3c1..5c7ffc8df362 100644
--- a/packages/astro/components/ViewTransitions.astro
+++ b/packages/astro/components/ViewTransitions.astro
@@ -53,6 +53,9 @@ const { fallback = 'animate' } = Astro.props;
if (supportsViewTransitions || getFallback() !== 'none') {
document.addEventListener('click', (ev) => {
let link = ev.target;
+ if (ev.composed) {
+ link = ev.composedPath()[0];
+ }
if (link instanceof Element) {
link = link.closest('a, area');
}
diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro
index e75c29f6350d..8e34eb555951 100644
--- a/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro
+++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro
@@ -12,6 +12,11 @@ import Layout from '../components/Layout.astro';
go to redirect 2
go to a redirect external
go to undefined page
+