Skip to content

Commit

Permalink
fix: possible mutation errors due to missing copy of updated options
Browse files Browse the repository at this point in the history
  • Loading branch information
gutentag2012 committed Nov 25, 2024
1 parent fc45910 commit c03edfc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/form-core/src/FormLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class FormLogic<
*/
public updateOptions(options?: FormLogicOptions<TData, TAdapter>): void {
const dirtyFields = this._dirtyFields.peek()
this._options.value = options
this._options.value = deepCopy(options)

if (options && 'disabled' in options) {
this._disabled.value = !!options.disabled
Expand All @@ -483,7 +483,7 @@ export class FormLogic<

this._skipValidation = true
// We do not want to update dirty field values, since we do not want to reset the form, but just override the default values
const newDefaultValues = { ...options.defaultValues }
const newDefaultValues = options.defaultValues
for (const dirtyField of dirtyFields) {
setValueAtPath(
newDefaultValues,
Expand Down

0 comments on commit c03edfc

Please # to comment.