-
Notifications
You must be signed in to change notification settings - Fork 31
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
Validation trigger on group should re-validate on delete + new row #555
Comments
Potential breaking change and should maybe be pushed to a new major version. |
There are other issues related to validation which could be useful to look at in order to get a complete view of the validation area. |
I have an update on this, and a suggestion for a less breaking solution. It was originally thought we needed to introduce a breaking change for this to work, because adding a new row to a repeating group should (naturally) set all the fields in the group to empty values (and pass this as a single save operation to the backend). However, we can continue on with the current functionality and add this behaviour as an optional feature (in the form of a trigger) without breaking backwards compatibility. My new suggestion for a solution here is to add multiple triggers for operations the user is performing. I've read through the relevant discussions again, making sure this solution should cover the use-cases. So, right now this is our possibilities: {
"type": "Group",
"triggers": ["validation", "validateRow"]
} For most other form components, it's implicitly meant that these triggers are triggered when saving, and this is also the case for groups (but only repeating groups). That is, we run this trigger when the user clicks 'save and close' for a row. Triggering But for repeating groups, there are more actions than just saving. You can:
We have functionality to trigger validation on the entire row before action 4 completes, and action 3 will implicitly trigger a call to the backend (because we need to save the changes to the data model). As for the rest, we do not have any triggers for these. And we find there are two different results for these triggers; either: a. Saving An obvious candidate here is to support a trigger for saving a new row as soon as it is added ( Another candidate is triggering saving when opening or closing a row ( So in essence, my suggestion here would be to expand the {
"type": "Group",
"triggers": {
"addAndOpen": ["save"],
"openExisting": ["save", "validateRow"],
"delete": ["validateRow"], // Happens before actually deleting, and the 'save' will always trigger
"close": ["save", "validateRow", "validation"] // This is the existing functionality, apart from the new 'save'
}
} All of which would be backwards-compatible. |
I seem to be able to enter a state where the validation call is not being triggered when a row is added or deleted. Steps to reproduce:
ezgif-4-3a88aa90dd.mp4 |
Tested this with |
Description
Adding
"triggers": ["validation"]
on a repeating group component does not have very well-defined behaviour. It should be possible to add this trigger, and have server-side validations re-run on the group data. In the related Slack discussion, an app was set up to validate that a group had at least 1 row (using server-side validations, but this should be supported by the JsonSchema validation as well).Triggers on a repeating group should run when:
The validations on the group should not run when saving data inside a component, as that should only trigger validation if that trigger is set on the component itself.
Related issue(s)
The text was updated successfully, but these errors were encountered: