diff --git a/.changeset/fresh-games-confess.md b/.changeset/fresh-games-confess.md new file mode 100644 index 0000000000..fa6a0fe97c --- /dev/null +++ b/.changeset/fresh-games-confess.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes View Transition's form submission prevention, allowing `preventDefault` to be used. diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index 310f1865a9..e8e12ce3d3 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -94,7 +94,7 @@ const { fallback = 'animate' } = Astro.props; document.addEventListener('submit', (ev) => { let el = ev.target as HTMLElement; - if (el.tagName !== 'FORM' || isReloadEl(el)) { + if (el.tagName !== 'FORM' || ev.defaultPrevented || isReloadEl(el)) { return; } const form = el as HTMLFormElement;