Skip to content

Bug: Stores Does Not Automatically Update #536

Closed
@ChekeGT

Description

@ChekeGT
  • 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfirmedConfirmed bug, will be worked upon in a near release.sveltekit-2Related to SvelteKit 2

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions