Clear invalidated flag when prompt is re-saved with unchanged data#21
Clear invalidated flag when prompt is re-saved with unchanged data#21rmcew wants to merge 1 commit into
Conversation
When a prompt is externally invalidated (via another prompt's invalidUponChange), the invalidated flag is set but the prompt data is preserved. If the user re-saves the invalidated prompt without changing anything, equal() returns true and the entire update block — including setRequirementPromptsValid — is skipped. This leaves the prompt permanently stuck in an invalidated state, blocking navigation. Move a setRequirementPromptsValid call for the current prompt to before the equal() check so that any successful save always clears the invalidated flag. Ref: txstate-etc/va-certification#165
|
My concern is accidental autosaves in the reviewer UI. We try to prevent them but it's a very fragile thing. If we do this we may need to force invalidated reviewer prompts behind an edit modal instead of having their form be inline. |
|
Ah. I haven't gotten to the reviewer side yet so I didn't think of that wrinkle Whatever solution you think is appropriate is fine with me, it's just currently a bug causing issues downstream |
|
@wickning1 We discussed some time ago, but I thought this was per design. Reviewer to applicant invalidation: Applicant to reviewer: Both directions I'm pretty sure you wanted a change of data to confirm, and not just gloss over. Applicant change to reviewer is most risky as if we don't require a data mod (or extra data) then a reviewer could save without ever re-validating applicant details. |
|
That's true. @rmcew, help me understand the original ticket. Why was veteran disabled status marked as invalidated? Generally that feature is for reviewers telling the applicant they made a mistake. |
|
This is applicant-to-applicant. Here, we are changing the benefit situation, which changes which downstream prompts are available. To do that, we feed the prompts to invalidUponChange. The problem occurs when the invalidated prompt's stored data hasn't been cleared. The user re-saves identical data, equal() returns true, and the invalidated flag is never cleared. |
|
Ok, I took a look at the situation in VA Cert. In your case I think the better solution would be to include the list of documents they are confirming they've seen in the payload. Something like That solves this problem without needing invalidUponChange at all - you can code the requirement's There may still be a distinction to be made between "this prompt needs review because another prompt changed" (let's call it "checkAgain") and "this prompt is flatly incorrect and must be changed based on the answer to another prompt" (let's call it "mustCorrect"). Reviewer-to-applicant invalidations are usually mustCorrect - you were supposed to upload a driver license, the reviewer says you uploaded something else, you MUST try again. Applicant-to-reviewer will usually be checkAgain - I have uploaded a new document, hopefully it's a driver license, please review it but you can say the answer is still No. I had hoped that we could limit checkAgain to the reviewer UI, but I can see that I could be wrong about that. Perhaps we need to find some way to let the downstream developer declare the difference between |
Summary
invalidUponChange) and the user re-saves it without changing data,equal()returns true andsetRequirementPromptsValidis never called — leaving the prompt permanently stuck as invalidatedsetRequirementPromptsValid([prompt.key])call before theequal()check so any successful save clears the invalidated flagTest plan
invalidUponChangetargeting BRef: txstate-etc/va-certification#165