TanStack/Angular - Error when resetting the form
luishcastroc opened this issue · comments
Luis Castro commented
Describe the bug
When i add the functionality to "reset" the form it will break the implementation.
Your minimal, reproducible example
Steps to reproduce
- Open the Stackblitz
- add a button for clear using this code:
<button type="reset" (click)="form.reset()">
Clear
</button>
- click on any input and get out to get the validation error.
- click the clear button, validation should be gone
- click on any input and get out of it
- 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**
Corbin Crutchley commented
This should be fixed in the latest version