Skip to content

issue: Inconsistent reset behavior #13099

@PiotrSkrzynski88

Description

@PiotrSkrzynski88

Version Number

7.65.0

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/ptdm7n

Steps to reproduce

  1. Go to https://codesandbox.io/p/sandbox/ptdm7n
  2. Click on Submit
  3. Notice the submit data coming from defaultValues
  4. Click on Reset
  5. Notice the same submit data coming from defaultValues
  6. Click on Reset again
  7. Notice the data passed to reset() is now showing

It seems that a single call to reset({}) doesn't work. A double call produces the expected result.

Expected behaviour

  1. Go to https://codesandbox.io/p/sandbox/ptdm7n
  2. Click on Submit
  3. Notice the submit data coming from defaultValues
  4. Click on Reset - reset({})
  5. The form defaultValues = {}

I'm not sure if the intention was different, but it seems logical that anything passed to reset(...) should now be the new defaultValues (if keepDefaultValues option is not enabled)

What browsers are you seeing the problem on?

Chrome

Relevant log output

Submit {name: Object}
Reset using {}
Submit {name: Object}
Reset using {}
Submit {}

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions