TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.

Home Page:https://tanstack.com/form

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TanStack/Angular - Error when resetting the form

luishcastroc opened this issue · comments

Describe the bug

When i add the functionality to "reset" the form it will break the implementation.

Your minimal, reproducible example

https://stackblitz.com/github/tanstack/form/tree/main/examples/angular/simple?embed=1&theme=light&preset=node

Steps to reproduce

  1. Open the Stackblitz
  2. add a button for clear using this code:
<button type="reset" (click)="form.reset()">
        Clear
      </button>
  1. click on any input and get out to get the validation error.
  2. click the clear button, validation should be gone
  3. click on any input and get out of it
  4. you should see an error.
chunk-3AFBTSQG.js?v=a3ca62aa:6796 ERROR TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at Object.onUpdate (@tanstack_angular-form.js?v=7c012f42:961:38)
    at Store.setState (@tanstack_angular-form.js?v=7c012f42:43:87)
    at @tanstack_angular-form.js?v=7c012f42:681:24
    at Store.batch (@tanstack_angular-form.js?v=7c012f42:60:7)
    at @tanstack_angular-form.js?v=7c012f42:674:20
    at @tanstack_angular-form.js?v=7c012f42:53:9
    at Set.forEach (<anonymous>)
    at Store._flush (@tanstack_angular-form.js?v=7c012f42:50:22)
    at Store.setState (@tanstack_angular-form.js?v=7c012f42:44:12)
    ```

### Expected behavior

The form should be cleared and validators should reset with no errors.

### How often does this bug happen?

Every time

### Screenshots or Videos

_No response_

### Platform

- OS: Mac OS
- Browser: Chrome Version 123.0.6312.107 (Official Build) (arm64)

### TanStack Form adapter

None

### TanStack Form version

@tanstack/angular-form": "^0.19.0"

### TypeScript version

5.4.2

### Additional context

There's no option to add the proper platform to the issue but the platform is **Angular**

This should be fixed in the latest version