Skip to content

Commit

Permalink
fix: all tests now pass
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed Jun 22, 2024
1 parent 9850290 commit 1678f84
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/form-core/src/FormApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,12 @@ export class FormApi<
: never,
opts?: { touch?: boolean },
) => {
this._tempDefaultValue = { value, field } as never
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const fieldVal = (this.getFieldValue(field) as unknown[]) ?? []
this._tempDefaultValue = {
value,
field: `${field}[${fieldVal.length}]`,
} as never
this.setFieldValue(
field,
(prev) => [...(Array.isArray(prev) ? prev : []), value] as any,
Expand All @@ -976,7 +981,7 @@ export class FormApi<
: never,
opts?: { touch?: boolean },
) => {
this._tempDefaultValue = { value, field } as never
this._tempDefaultValue = { value, field: `${field}[${index}]` } as never
this.setFieldValue(
field,
(prev) => {
Expand Down Expand Up @@ -1004,7 +1009,7 @@ export class FormApi<
: never,
opts?: { touch?: boolean },
) => {
this._tempDefaultValue = { value, field } as never
this._tempDefaultValue = { value, field: `${field}[${index}]` } as never
this.setFieldValue(
field,
(prev) => {
Expand Down

0 comments on commit 1678f84

Please sign in to comment.