Conversation
🦋 Changeset detectedLatest commit: a2b67da The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
||
| export interface Props { | ||
| fallback?: Fallback; | ||
| form?: boolean; |
There was a problem hiding this comment.
I like the idea of using these props to select deviant behavior.
Looking at the uses, handleForms seems more intuitive?
There was a problem hiding this comment.
Or maybe animateForms or something similar? Astro doesn't handle anything other than catching the submit and passing everything to the endpoint. "Handle" could be misunderstood like validation, error management, etc.
There was a problem hiding this comment.
We don't use the word animate as animations are a use-case but not what the feature actually does. You can actually use this router and have no animations at all.
|
In the Navigate API, the Navigate event has a property for form data, but it is not clear from the specification how this property is set. I don't see a problem if Astro's |
ematipico
left a comment
There was a problem hiding this comment.
Can we add a test case with a failure when doing a submit? I would like to see/understand what's the expected behaviour in that case
|
@ematipico You mean if the API responds with a 400/500? I can add that. |
Yeah exactly, just to get a sense of the expected behaviour. Cheers! |
|
@martrapp I have updated the API per your suggestion to use @ematipico I've added a test which causes regular transitions for non-200 responses. |
sarah11918
left a comment
There was a problem hiding this comment.
Looks great @matthewp ! Made some suggestions to the changeset below! Basically, I'm gonna need a bit more hypeeeee 🥳
.changeset/many-weeks-sort.md
Outdated
|
|
||
| Form support in ViewTransitions router | ||
|
|
||
| The `<ViewTransitions />` router can now handle form submissions, allowing you to retain stateful UI. This feature is opt-in for semver reasons and can be enabled by adding the `handleForms` prop to the component like so: |
There was a problem hiding this comment.
| The `<ViewTransitions />` router can now handle form submissions, allowing you to retain stateful UI. This feature is opt-in for semver reasons and can be enabled by adding the `handleForms` prop to the component like so: | |
| The `<ViewTransitions />` router can now handle form submissions, allowing you to trigger in-page transitions from a form submission while keeping page state. This feature is opt-in and can be enabled by adding the `handleForms` prop to the routing component: |
I'm gonna need you to sell forms to me harder than this, Matthew. 😅
Can you do better than "retain stateful UI"? Something that more walks through the (exciting!) process itself? People are always asking about forms, can we hype this in a more "give the people what they want" kind of way?
There was a problem hiding this comment.
All right, I needed the pep-talk. Pushed with a bit more, trying to emphasize that this addition completes the circle of everything you need to stay in the client if that's what you want.
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
|
I'm happy with the fact that we're adding properties that come later from the Navigation API as additional fields in NavigationNavigateOptions. And the new property in ViewTransitions is now also more descriptive. Everything looks good to me! The only thing I was wondering is if the popstate handler needs to be customized as well. After all, it always passes an empty options object. But I think it's fine the way it is. An app would prevent users from returning to the form after the "post". And with a multi-page form, you would disable the "forward" after navigating back. |
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Support form submissions in the ViewTransitions router * Align with navigate API, add `formData` option * Change API to handleForms * Add a changeset * Add a test for non-200 responses * Update .changeset/many-weeks-sort.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/many-weeks-sort.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Add a little more on why this is exciting! * Update .changeset/many-weeks-sort.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Switch to e.g. --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
formoption on the ViewTransitions router:<ViewTransitions form />. Probably there is a better name.data-astro-reloadlike with anchors, to opt-out on a per form basis.navigate()APIoptions.initwhich is aRequestInit. This is needed for forms to provide the body and set the method on the request.Testing
Docs