mobx-react-form icon indicating copy to clipboard operation
mobx-react-form copied to clipboard

Invalid Field Instance exception when unmounting control while being validated even in demo page

Open codebury opened this issue 7 years ago • 4 comments

Hi,

My code:

@computed ready = false
...
{ this.ready ? <MyFieldset key={item.key} field={item} onAdd={item.onAdd} onDelete={item.onDel} onCancel={() => this.ready = false} /> : null }

Demo steps:

  1. Select "Nested Fields".
  2. Scroll to end and delete all Charlie Chaplin's hobbies.
  3. Click on Add Hobbies and focus the textbox.
  4. Finally, click on delete.

(Sorry, cannot upload images) Unhandled rejection Error: Validation Error: Invalid Field Instance at Q (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1346) at A.e (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1231) at Q (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1346) at A.e (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1231) at t.validate (https://foxhound87.github.io/mobx-react-form-demo/main.js:40:26827) at i (https://foxhound87.github.io/mobx-react-form-demo/main.js:35:28269) at T (https://foxhound87.github.io/mobx-react-form-demo/main.js:35:28558) at u (https://foxhound87.github.io/mobx-react-form-demo/main.js:35:28491)

Inside MyFieldset there is a textbox. When I click on cancel button, the control still being on validating process. I suppose that mobx observables are unmounted too late so when the validation process finishes, the control no longer exists.

I think there must be a method that allows the form to be destroyed in the component unmounting process or something similar.

Best regards.

codebury avatar Feb 14 '18 15:02 codebury

Any chance of getting a fix for this? 🙏🏻

derekcannon avatar Sep 04 '19 03:09 derekcannon

@derekcannon I still have to figure it out.

foxhound87 avatar Sep 05 '19 09:09 foxhound87

any progress on this? would be really grateful for a fix

eyrwen avatar Aug 24 '21 00:08 eyrwen

For anyone coming here after me: Setting the options in the Form constructor to be

new Form({...}, {options: { validateOnBlur: false, validateOnChange: true}})

got around the issue for me.

eyrwen avatar Aug 24 '21 16:08 eyrwen

:tada: This issue has been resolved in version 5.4.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Mar 13 '23 08:03 github-actions[bot]