useFieldArray move
+ submitting form causes nested children arrays to be added to the wrong parent
#11051
Replies: 2 comments
-
After too long of a time debugging, I ended up fixing (hopefully) this edge case by adding I'm guessing that there's some state mismatch when you try to drag too quickly after the first onDragEnd since state updates are batched. Forcing state update with Though it still would help if someone provide more context around how Code for context in case anyone runs into this in the future:
|
Beta Was this translation helpful? Give feedback.
-
set |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.47.0
Codesandbox/Expo snack
N/A
Steps to reproduce
I don't have a code example at the moment, will try to put one together if I have time. But in the meantime, here is my setup, the steps I take to repro, and some screenshots.
Setup:
useForm
Issue
Dragging and dropping using
move
causes the children of one top level element to be copied over to the other. It seems to weirdly depend on how quickly Imove
the items around or how quickly I click Submit.This is the starting state. I'll be referencing each top level item with their index.
Steps to repro:
move
in code)move
in code)reset
the form to use the current form state.Incorrect result:

Expected behaviour
Similar steps, but no repro:
move
in code)move
in code)OR
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions