diff options
author | 2023-12-20 14:44:48 +0100 | |
---|---|---|
committer | 2023-12-20 14:44:48 +0100 | |
commit | f6714f677cffa2484565f51d5eb55bd34309653b (patch) | |
tree | 10ca17bd88c152c4b552777846ae365469200110 | |
parent | 5062d27a186c5020522614b9d6f3da218f7afd96 (diff) | |
download | astro-f6714f677cffa2484565f51d5eb55bd34309653b.tar.gz astro-f6714f677cffa2484565f51d5eb55bd34309653b.tar.zst astro-f6714f677cffa2484565f51d5eb55bd34309653b.zip |
view transition's form handling honors default prevention (#9486)
* add missing check to honor prevented default
* added changeset
* Update .changeset/fresh-games-confess.md
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
---------
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
-rw-r--r-- | .changeset/fresh-games-confess.md | 5 | ||||
-rw-r--r-- | packages/astro/components/ViewTransitions.astro | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/fresh-games-confess.md b/.changeset/fresh-games-confess.md new file mode 100644 index 000000000..fa6a0fe97 --- /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 310f1865a..e8e12ce3d 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; |