final-form / react-final-form-arrays

A component for rendering and editing arrays 🏁 React Final Form
MIT License
204 stars 69 forks source link

Conditionally visible FieldArrays pushing to wrong field #142

Closed gidomanders closed 4 years ago

gidomanders commented 4 years ago

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

I have 2 FieldArrays in bootstrap tabs based on routing, so the fields are displayed conditionally. The steps is the first field you see. When you add one step, it gets pushed to the steps array. When you switch tabs to questions and add a question, the question gets pushed to the steps array instead of the questions array.

What is the expected behavior?

I expect the question to be added to the questions array, so to the property the name refers to instead of the first field FieldArray is initialized with on window load.

Sandbox Link

https://codesandbox.io/s/youthful-wave-e4t0h

What's your environment?

gidomanders commented 4 years ago

Removing the Switch around the Route's in my component solved my problem.