Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form sends onChange before conditional re-validation applied #57

Open
mrclay opened this issue Mar 30, 2018 · 3 comments
Open

Form sends onChange before conditional re-validation applied #57

mrclay opened this issue Mar 30, 2018 · 3 comments

Comments

@mrclay
Copy link
Contributor

mrclay commented Mar 30, 2018

We have lots of required conditionally displayed questions and the Form's onChange is firing too early, sending us the set of errors before the revalidation of the new schema has been completed.

Our current workaround is to have several of our widgets (ones which affect others) call onChange a second time after a short delay. After the delay the Form internally has the correct set of errors considering all rules.

@mavarazy
Copy link
Contributor

mavarazy commented May 22, 2018

@mrclay Can you provide an example of a form and change that is happening.
Thanks in advance.

nbroda-carecloud pushed a commit to nbroda-carecloud/react-jsonschema-form-conditionals that referenced this issue Jun 6, 2018
EAG-219 Padding added at the bottom of the plan section
@i-Living
Copy link

i-Living commented May 21, 2019

Faced the same issue. Here is my example:

schema: {
	"type": "object",
	"required": [
	  "field2"
	],
	"properties": {
	  "checkbox": {
	    "type": "boolean",
	    "default": false
	  },
	  "field1": {
	    "type": "string"
	  },
	  "field2": {
	    "type": "string"
	  }
	}
}
rules: [{
	"conditions": {
	 "checkbox": {
	    "is": true
	 }
	},
	"event": [
	  {
	    "type": "remove",
	    "params": {
	      "field": [
	        "field2"
	      ]
	    }
	  },
	  {
	    "type": "require",
	    "params": {
	      "field": [
	        "field1"
	      ]
	    }
	  }
	]
}]

When you submitting form you will get required field2 in errors
After applying checkbox onChange event still handling error in field2 which is not exist on form.
The only way to overrite errors is to submit the form but in real app there are cases that prevent me from using it.

@mrclay
Copy link
Contributor Author

mrclay commented May 21, 2019

I'm sorry I've not been able to provide an example form. They're all large and use many custom widgets/fields, and to be fair it's quite possible our problems lie there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants