Closed LouisHaftmann closed 3 months ago
When calling .update(newOpts) on a FormApi instance, the form options are overwritten instead of merged.
.update(newOpts)
FormApi
Example:
const form = new FormApi({ asyncDebounceMs: 5000, }); // prints `{ asyncDebounceMs: 5000 }` console.log(form.options); form.update({ defaultValues: { test: '', }, }); // prints `{ defaultValues: { test: '' } }` console.log(form.options);
https://stackblitz.com/edit/stackblitz-starters-hvxmtx?file=index.ts
form.update(newOpts)
I would expect the options to get merged instead of overwritten
Every time
No response
None
v0.26.4
This line is the cause of this bug: https://github.com/TanStack/form/blob/bde3b1cb3de955b47034f0bfaa43dec13c67999a/packages/form-core/src/FormApi.ts#L471
This is correct behavior. You can merge options yourself using {...this.field.options, other: someVal}
{...this.field.options, other: someVal}
Describe the bug
When calling
.update(newOpts)
on aFormApi
instance, the form options are overwritten instead of merged.Example:
Your minimal, reproducible example
https://stackblitz.com/edit/stackblitz-starters-hvxmtx?file=index.ts
Steps to reproduce
form.update(newOpts)
Expected behavior
I would expect the options to get merged instead of overwritten
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
TanStack Form adapter
None
TanStack Form version
v0.26.4
TypeScript version
No response
Additional context
This line is the cause of this bug: https://github.com/TanStack/form/blob/bde3b1cb3de955b47034f0bfaa43dec13c67999a/packages/form-core/src/FormApi.ts#L471