I have a form which has an array input, inside there are fields which are displayed conditionally based on a type field. When I add a new item and move it above an existing one, then select the same type as the the one that was previously at that index. It copies the old field values from the item previously at that index to the new one.
What you were expecting:
When reordering a new item and selecting the type I expect the fields not to be populated with any data.
What happened instead:
Fields were populated with existing data from the item previously at that index
Steps to reproduce:
I have created a stackblitz to reproduce the issue
ApplicationCode
Add a new card to the array
Move the card up above the existing editorial card
Select the editorial type (same as the card that was at this index before)
Observe the field value from the card that was previously at that index is injected into the new field
I have a form which has an array input, inside there are fields which are displayed conditionally based on a type field. When I add a new item and move it above an existing one, then select the same type as the the one that was previously at that index. It copies the old field values from the item previously at that index to the new one.
What you were expecting: When reordering a new item and selecting the type I expect the fields not to be populated with any data.
What happened instead: Fields were populated with existing data from the item previously at that index
Steps to reproduce: I have created a stackblitz to reproduce the issue Application Code
Here's a video to demonstrate
https://user-images.githubusercontent.com/8376300/194025927-3e097199-8396-46cf-9ad8-7a0a7729d427.mov
Related code: https://stackblitz.com/edit/react-c8qwgj?file=src/App.js Here is the edit form I'm using
Environment