Skip to content

issue: useFieldArray re-insert removed items automatically with keepDirtyValue #12489

@djhi

Description

@djhi

Version Number

7.54.1

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/busy-currying-qsv3fs?file=%2Fsrc%2FApp.tsx

Steps to reproduce

Note that the keepDirtyValue option must be set for this to happen.

  1. Add an element to the array by clicking Append and fill its value
  2. Submit the form
  3. Delete the element you added
  4. Submit the form
  5. Delete the only element left
  6. Submit the form
  7. Click Append

Notice two empty elements were added.

Expected behaviour

I expect the array to be reliable. It should only have added one element at step 7.

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions