Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<ViewTransitions /> causes error, treats <form method="post"> as <form method="get"> #9368

Closed
1 task
thuongvux opened this issue Dec 7, 2023 · 2 comments
Closed
1 task
Labels
needs triage Issue needs to be triaged

Comments

@thuongvux
Copy link

Astro Info

Astro                    v4.0.3
Node                     v21.2.0
System                   Linux (x64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/vercel/serverless
Integrations             @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Enable <ViewTransitions /> causes error
Submit form <form action="/api/example" method="post"> will not work and it will treat like <form action="/api/example" method="get">
I have temporary solutions is disable <ViewTransitions /> or go back to Astro v3.6.4.

What's the expected result?

Open stackblitz link to see!

Link to Minimal Reproducible Example

https://stackblitz.com/~/github.com/thuongvux/thuongvux-astro-v4.0.3-viewtransitions-issue

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 7, 2023
@thuongvux thuongvux changed the title <ViewTransitions /> causes error, treat <form method="post"> as <form method="get"> <ViewTransitions /> causes error, treats <form method="post"> as <form method="get"> Dec 7, 2023
@martrapp
Copy link
Member

martrapp commented Dec 7, 2023

Hi @thuongvux,
in 3.x you had to explicitly enable view transitions for forms:

<ViewTransitions handleForms/>

In 4.x form handling is active by default, see CHANGELOG.md entry for 4.0.0:

#9225 c421a3d17 Thanks @natemoo-re! - Removes the opt-in handleForms property for <ViewTransitions />. Form submissions are now handled by default and this property is no longer necessary. This default behavior can be disabled by setting data-astro-reload on relevant <form /> elements.

For your example:

<form action="/api/example" method="post" data-astro-reload>

@martrapp martrapp closed this as completed Dec 7, 2023
@Titou325
Copy link

Hi! Stumbled across this as well. Maybe we could add a reference in https://docs.astro.build/en/recipes/build-forms/ as well to prevent this from happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants