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

Custom callback for when submission is completed #371

Open
saturnonearth opened this issue Mar 1, 2024 · 5 comments
Open

Custom callback for when submission is completed #371

saturnonearth opened this issue Mar 1, 2024 · 5 comments
Labels
enhancement New feature or request later May be worked on in the future.

Comments

@saturnonearth
Copy link
Sponsor

Is your feature request related to a problem? Please describe.
For example...if I am redirecting on login I want the loading spinner to stay on even though the form is done submitting.

Describe the solution you'd like
I think it would be cool to have $redirecting store, like $delayed and $submitting so we can easily track it.

Describe alternatives you've considered
I could just easily add a flag onResult but I think it would be nice to have the Store easily accessible, like the others are.

@saturnonearth saturnonearth added the enhancement New feature or request label Mar 1, 2024
@ciscoheat
Copy link
Owner

This is already included in the timers, if a redirect result is returned, then the SvelteKit navigation store is used to clear the timers. If that doesn't work for you, something isn't right. Can you make a MRE?

@saturnonearth
Copy link
Sponsor Author

This is already included in the timers, if a redirect result is returned, then the SvelteKit navigation store is used to clear the timers. If that doesn't work for you, something isn't right. Can you make a MRE?

Here is a MRE: https://stackblitz.com/edit/superforms-2-testing-qcncdj?file=src%2Froutes%2F%2Bpage.svelte

I wonder if it's because of the page transition?

@ciscoheat
Copy link
Owner

When I submit on the MRE, the spinner is visible up until the transition, isn't that how it's supposed to be?

@saturnonearth
Copy link
Sponsor Author

When I submit on the MRE, the spinner is visible up until the transition, isn't that how it's supposed to be?

Well technically speaking I suppose yes, but it's a little jarring during a transition when the button state changes. I could just add a flag but was thinking of a cleaner way to do this as it's a common pattern for me, and I often already have $delayed or $submitting on the submit button - but perhaps it's unnecessary

@ciscoheat
Copy link
Owner

Then I guess SvelteKit doesn't take transitions into account for the navigation store. Some future version of Superforms may have a custom callback for when the submission is determined to be completed, but not right now. :)

@ciscoheat ciscoheat added the later May be worked on in the future. label Mar 3, 2024
@ciscoheat ciscoheat changed the title $redirecting Store Custom callback for when submission is completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request later May be worked on in the future.
Projects
None yet
Development

No branches or pull requests

2 participants