Altinn / Altinn/app-frontend-react

Validation: Re-runs after every PATCH hammers slow `noIncrementalUpdates`-validation

Open
#4,137 2 comments 0 reactions 0 assignees View on GitHub
area/validation kind/bug org/krt squad/data
Dominant language
TypeScript
Stars
21
Forks
33
Avg merge
6d 23h
Merged PRs (30d)
3

Description

### 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:

https://github.com/Altinn/app-frontend-react/blob/84ff8ffdc9f1560cb1207364fb9a554e1c758ef2/src/features/validation/validationContext.tsx#L283-L296

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

1. Trigger the 'showAllErrors' validation mode
2. Make changes to form data
3. Observe a call to `/validate` happens after every PATCH

### Additional Information

A somewhat long discussion about the topic:
- https://digdir.slack.com/archives/C09BLD1CRK8/p1776755165638949

Contributor guide

Open the contributing guide

Research direction

Start with src/features/validation/validationContext.tsx at lines 283-296 and reproduce the issue by enabling showAllErrors, changing form data, and observing /validate after each PATCH. Review the changes from #2462 and the issue discussion; done means slow noIncrementalUpdates validation no longer runs after every PATCH while explicit re-validation, such as form submission, still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.