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

Posted store is set to true even when data is invalid #407

Open
shellicar opened this issue Apr 12, 2024 · 5 comments
Open

Posted store is set to true even when data is invalid #407

shellicar opened this issue Apr 12, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@shellicar
Copy link

Description
The posted store returned from the superForm function is set to true whenever the form is submitted, even when it fails to submit with a success result.

This worked up until version 2.7.0, and seems to have broken in 2.8.0.

MRE

<script>
// ...
const { form, errors, message, posted, enhance } = superForm(data.form);
</script>

<pre>{JSON.stringify({
	posted: $posted
})}</pre>
@shellicar shellicar added the bug Something isn't working label Apr 12, 2024
@ciscoheat
Copy link
Owner

The intent of posted is to be true as soon as the form has been posted.

@shellicar
Copy link
Author

I'm not sure I understand your response.
What is the definition of posted?
Surely the sequence is submitting -> posted?
How can the form be posted if it was never submitted?

The way it has always worked is that unless the form is posted to the server, posted is not set to true.
If the data is invalid with client-side validation, then there is no submission and therefore posted is not true.
If the cancel function is called during onUpdate, it is also not set to true.
At least when the SPA mode is set to true.

This change completely breaks the functionality that I have been depending on and has been that way since I started using the library in 1.x.

If the data is not posted to the server because of errors, then it is not posted, correct?
If this was intended to change or be "fixed", why is it not noted in the release notes for 2.8.0?
And if so, what store can I use to determine if the form has been submitted succesfully to the server?

@ciscoheat
Copy link
Owner

You expect too much, it's an open source project. Please contribute some falling tests if you've found a regression.

@shellicar
Copy link
Author

For what it's worth this is currently my favourite library, and I really appreciate all the work and effort that is going in it, and to maintain it.

It seems like you think I am being unreasonable. I am reporting what I believe is a bug.
I felt that your initial response was quite dismissive, and made it seem like it wasn't a bug or was by design, so I provided more information and seek clarification.
What expectations do you think I have that are too much?

I am willing to conceded that the behaviour I am depending on is not specifically intended in SPA mode.
I am probably in the minority when it comes to the way that I use sveltekit & superforms.
But there doesn't seem to be enough information on what the posted store is intended for use for and how it behaves in certain situations.

I have spent a lot of time investigating every bug I encounter in order to make sure it is a bug, even tracking down the exact version change that it happened in. And testing things out in the REPLs (which are often quite buggy) to make sure it's not something weird going on in my machine.

I'd be happy to contribute if it helps improve the library, although my time is quite limited at the moment.
If you can point me in the right direction for writing some tests, I'll have a look when I have a chance.

@ciscoheat
Copy link
Owner

You seem to expect no regressions and that the documentation and changelog should be fully updated, which is unrealistic for an open source project with a single maintainer and a few very kind sponsors.

You say your time is quite limited, well, it's the same for others. But that's how it is with OSS, you pay with your time.

superForm and superValidate are the two functions that should be used for testing the posted store, here they are: https://github.com/ciscoheat/sveltekit-superforms/tree/main/src/tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants