Description of the bug
On the backend, we have a validation concept called noIncrementalUpdates, specifically made for cases where validation is slow (i.e. when it needs API lookups or complex checks). We want to reduce the calls to run these validations until we absolutely have to.
On the frontend, we now have a trigger that can cause this validation to run way too often:
|
// Since process/next returns non-incremental validations, we need to also check these to see when they are removed |
|
const refetchInitialValidations = useRefetchInitialValidations(false); |
|
useEffect(() => { |
|
// No need to invalidate initial validations right away |
|
if (isFirstRender.current) { |
|
isFirstRender.current = false; |
|
return; |
|
} |
|
// Adding or deleting an attachment can lead to changes in both the data model and an update |
|
// in the attachments data elements, which can lead to two updates right after each other, |
|
// so debouncing a little so that we don't call validate too much as it can be heavy. |
|
const timer = setTimeout(() => refetchInitialValidations(), 1000); |
|
return () => clearTimeout(timer); |
|
}, [refetchInitialValidations, instanceDataChanges, lastSaved]); |
This was introduced in #2462, which had fixes for some validation issues. We should look into finding a better fix for this, while trying our best to keep the user experience at the current level (or not that far below the one we have now). Fixing this is expected to cause slow-running validations to not update in the UI unless the user explicitly triggers re-validation (i .e. by trying to submit the form, or some other interaction). It might be wise to take a step back and look into introducing a button for letting the user re-validate in cases like this.
Steps To Reproduce
- Trigger the 'showAllErrors' validation mode
- Make changes to form data
- Observe a call to
/validate happens after every PATCH
Additional Information
A somewhat long discussion about the topic:
Description of the bug
On the backend, we have a validation concept called
noIncrementalUpdates, specifically made for cases where validation is slow (i.e. when it needs API lookups or complex checks). We want to reduce the calls to run these validations until we absolutely have to.On the frontend, we now have a trigger that can cause this validation to run way too often:
app-frontend-react/src/features/validation/validationContext.tsx
Lines 283 to 296 in 84ff8ff
This was introduced in #2462, which had fixes for some validation issues. We should look into finding a better fix for this, while trying our best to keep the user experience at the current level (or not that far below the one we have now). Fixing this is expected to cause slow-running validations to not update in the UI unless the user explicitly triggers re-validation (i .e. by trying to submit the form, or some other interaction). It might be wise to take a step back and look into introducing a button for letting the user re-validate in cases like this.
Steps To Reproduce
/validatehappens after every PATCHAdditional Information
A somewhat long discussion about the topic: