react-final-form-arrays icon indicating copy to clipboard operation
react-final-form-arrays copied to clipboard

FieldArray's unshift mutator does not update state correctly

Open rrjohnson85 opened this issue 7 years ago • 6 comments

Are you submitting a bug report or a feature request?

Bug

What is the current behavior?

When using the unshift mutator to add an item to the beginning of an array, the touched state from the item previously at index zero (if one exists) is maintained.

What is the expected behavior?

I would expect the item that was added to the beginning of the array to have a touched state of false.

Sandbox Link

N/A, but I will happily provide one if needed.

What's your environment?

  • final-form: 4.8.3
  • react-final-form: 3.6.4
  • final-forms-array: 1.0.4
  • react-final-forms-array: 1.0.6
  • React: 16.4.1
  • Chrome: 68.0.3440.75

Other information

N/A

rrjohnson85 avatar Jul 25 '18 16:07 rrjohnson85

Hello,

If it can help for further investigation, I think it might be related to #33

tatchi avatar Aug 09 '18 12:08 tatchi

I have a similar issue. I am noticing that the meta associated with a field is not moved with the input values. So, when you move things around with mutators, the input is moved, but is then associated with the meta from whatever previously existed at the new index.

This is particular problematic with Drag-and-drop. My field moves, but the meta, which includes things like dirty, pristine, touched, valid, etc, all stay associated with the wrong input values.

311chaos avatar Aug 21 '18 23:08 311chaos

this should be resolved in [email protected]

311chaos avatar Aug 23 '18 21:08 311chaos

@311chaos sweet, I'll try it out and report back.

rrjohnson85 avatar Aug 23 '18 21:08 rrjohnson85

No. This is not resolved. In fact, my [email protected] fix mistakenly assumed that that sort of movement was the only problem, but unshift is a different beast. ⚠️ Still in progress.... ⚠️

erikras avatar Aug 23 '18 21:08 erikras

Have similar problem

dima19972525 avatar Jul 18 '19 08:07 dima19972525