Skip to content

Commit

Permalink
Note non-standard behavior of view transitions for forms set to post
Browse files Browse the repository at this point in the history
  • Loading branch information
knpwrs authored Dec 19, 2023
1 parent c91ca92 commit 2a4e985
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/content/docs/en/guides/view-transitions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ The `<ViewTransitions />` router will trigger in-page transitions from `<form>`

By default, your page will transition after a form is submitted, even if you are using `event.preventDefault()` to prevent this behavior.

Please note that if your method is set to `post`, the default behavior of web browsers is to submit your form data encoded as as `application/x-www-form-urlencoded`, but the default behavior of Astro is to submit your form data as `multipart/form-data`. If you want to match the default behavior of web browsers make sure to set the `enctype` attribute accordingly:

```astro title="src/components/Form.astro"
<form action="/contact" method="post" enctype="application/x-www-form-urlencoded">
<!-- -->
</form>
```

You can opt out of router transitions on any individual form using the `data-astro-reload` attribute:

```astro title="src/components/Form.astro"
Expand Down

0 comments on commit 2a4e985

Please sign in to comment.