final-form / react-final-form-arrays

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

Try to move Fields with Conditions not working #25

Open vyrruss opened 6 years ago

vyrruss commented 6 years ago

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

When I try to Drag and Drop group of Fields with conditions to be displayed or not in a FieldArray, there is an error happening: "Cannot read property 'active' of undefined"

If you try to reproduce it from the sandbox linked below:

  1. Create several customers
  2. Enter on one of them "test" to validate the condition to display the lastName
  3. Try to Drag and Drop a customer with the handler on the left "::"
  4. The error come here 🔴

What is the expected behavior?

The expected behavior is to be able to move Fields that have Conditions Fields inside

Sandbox Link

Edit 🏁 React Final Form - Field Arrays

erickjth commented 6 years ago

+1

311chaos commented 6 years ago

@vyrruss - Did you ever find a solution? I am coming across this same issue in my app, but using ReactDnd.

Somewhere in the docs it mentions Drag and Drop support, however we have two different drag and drop solutions with the same error.

How can I make sure it is safe to call "move" without blowing up my application?

Edit - wrapping the form move in a try {} catch(e) {console.log('Move exploded')} does keep the app from dying, but it feels bad to do that.

vyrruss commented 6 years ago

@311chaos Hey I didn't have the time to look for solutions, however I wanted to try an other library for forms and I used on an other project Formik and have no issues with the Drag and Drop to move FieldArray.

maciejmyslinski commented 6 years ago

I tried to work on it. I found out it's because notifyFieldListeners function doesn't expect field to be undefined. Then publishFieldState is called with an undefined as a second argument and the whole thing crashes.

https://github.com/final-form/final-form/blob/4bf30f058f027db50b4e39e013356f95423bb79b/src/FinalForm.js#L436-L443

Now I need help because I don't know how to write a test that would duplicate the behavior. @erikras any guidance?

alex-shatalov commented 5 years ago

just visited the sandbox link of this issue. Updated final-form-arrays from 1.0.4 -> 1.1.0 and react-final-form-arrays 1.0.4 -> 1.1.0 and catch strange bug. link and video below. https://codesandbox.io/s/q30rr3k0m4 screencast 2018-11-15 11-19-12

HawiCaesar commented 5 years ago

@alex-shatalov what is the <Condition /> for ?

HawiCaesar commented 5 years ago

@maciejmyslinski have you come up with something yet ?

maciejmyslinski commented 5 years ago

@vyrruss the codesandbox you provided is not working anymore. Could you please fix it?

I'll work on it if I can reproduce it 🙂