8000 [@tanstack/svelte-form] Form Subscribe property "isSubmitting" is not reactive · Issue #1513 · TanStack/form · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[@tanstack/svelte-form] Form Subscribe property "isSubmitting" is not reactive #1513

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

Closed
SiNONiMiTY opened this issue May 15, 2025 · 2 comments

Comments

@SiNONiMiTY
Copy link

Describe the bug

The example provided on the documentation

https://tanstack.com/form/latest/docs/framework/svelte/guides/validation#preventing-invalid-forms-from-being-submitted

The props provided by the children() snippet are not reactive. I was trying to debug the example and see if the canSubmit & isSubmitting flags are changing

  {#snippet children(state)}
    <button type="submit" disabled={!state.canSubmit}>
      {state.isSubmitting ? '...' : 'Submit'} // Text never changes after submission
    </button>
  {/snippet}

The text on the button never changes, but a separate (@debug state.isSubmitting} indeed shows the value is changing but is not re-rendered.

Using a separately declared variable to track the submission with $state() on top level works as expected.

Your minimal, reproducible example

N/A

Steps to reproduce

Follow the example on the documentation

Expected behavior

The state variables must be reactive so it can be re-rendered

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

Mozilla Firefox 139.0b8

TanStack Form adapter

None

TanStack Form version

@tanstack/svelte-form: 1.11.1

TypeScript version

5.8.3

Additional context

No response

@SiNONiMiTY
Copy link
Author

Found a related issue

https://github.com/ralf-boltshauser/tanstack-form-isSubmitting-issue

Tried the approach of converting the validators (onBlur, onChange) to their async counterparts and the isSubmitting value is updated, but only on the second click of the submit button

@SiNONiMiTY SiNONiMiTY changed the title [@tanstack/svelte-form] Form Subscribe properties "canSubmit", "isSubmitted" are not reactive [@tanstack/svelte-form] Form Subscribe property "isSubmitting" is not reactive May 24, 2025
@SiNONiMiTY
Copy link
Author

Closing issue, did a thorough investigation and it seems that some of 6979 the async operations on onSubmit were not awaited properly

Using @tanstack/svelte-form along with @tanstack/svelte-query and here is a snippet of the integration

const query = createMutation({
    mutationKey: [
        'query',
    ],
    mutationFn: async (data) => {
        // LOGIC
    },
})

const form = createForm(() => ({
    onSubmit: async ({ value }) => {
        await new Promise<void>((resolve, reject) => {
            $query.mutateAsync(value, {
                onSuccess: () => resolve(),
                onError: () => reject(),
            })
        })

        // OR

        await $query.mutateAsync(value)
    },
    // OTHER PROPS
})

For those that will stumble into this issue, make sure you properly await all async operations and/or for callback-based operations, promisify those operations to make sure that the isSubmitting variable can properly track the submission status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0