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

Bug: Error Store Does Not Automatically Update #536

Open
1 task done
ChekeGT opened this issue Dec 19, 2024 · 6 comments
Open
1 task done

Bug: Error Store Does Not Automatically Update #536

ChekeGT opened this issue Dec 19, 2024 · 6 comments
Labels
bug Something isn't working confirmed Confirmed bug, will be worked upon in a near release. sveltekit-2 Related to SvelteKit 2

Comments

@ChekeGT
Copy link

ChekeGT commented Dec 19, 2024

  • Before posting an issue, read the FAQ and search the previous issues.

Description

The error store does not automatically update when an error changes.

A form can only be submitted if all fields are error-free. However, in this library, the error state does not update to reflect new errors if we trigger a new one immediately.

Only happens when use:enhance is turned on

Steps to Reproduce

  1. Submit the form with an invalid field to trigger an error.
  2. Resolve the initial error.
  3. Trigger, at the same time a new error on the form.

Expected Behavior

The error store should update automatically to reflect the new errors.

Actual Behavior

The new error is not reflected in the UI, leading to inconsistencies.

This produces some weird side effects, like not reacting to errors when submitting the form for a second time

Workaround

A hacky workaround involves manually updating the error store using the onUpdate option:

const { form, errors, message, enhance } = superForm(data.form, {
	applyAction: true,
	// Hacky way to FIX this
	onUpdate: ({ form }) => {
		$errors = form.errors;
	},
});

If applicable, a MRE
Use this template project to create a minimal reproducible example that you can link to here: link to open in a new tab)

@ChekeGT ChekeGT added the bug Something isn't working label Dec 19, 2024
@ciscoheat
Copy link
Owner

I've got other reports for this, so will take a look at it now

@ciscoheat
Copy link
Owner

ciscoheat commented Dec 19, 2024

Something breaks in the latest version of SvelteKit.

Workaround: If you use "@sveltejs/kit": "2.11.1" in package.json it works again.

@ciscoheat
Copy link
Owner

ciscoheat commented Dec 19, 2024

Seems to be some problem with applyAction, it does not trigger a page update after the first request.

@ciscoheat ciscoheat added help wanted Extra attention is needed confirmed Confirmed bug, will be worked upon in a near release. sveltekit-2 Related to SvelteKit 2 labels Dec 19, 2024
@ciscoheat
Copy link
Owner

This line doesn't trigger the page update anymore, which in turn prevents the update code to run.

@ciscoheat
Copy link
Owner

Possibly related to https://svelte.dev/docs/kit/$app-state

@ciscoheat
Copy link
Owner

Reported on SvelteKit here: sveltejs/kit#13200

@ciscoheat ciscoheat removed the help wanted Extra attention is needed label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed Confirmed bug, will be worked upon in a near release. sveltekit-2 Related to SvelteKit 2
Projects
None yet
Development

No branches or pull requests

2 participants