Skip to content

Commit ded240c

Browse files
committed
LIBDRUM-909. Fix race condition in validation error display after deposit
When depositing with missing required fields, the backend returns errors that trigger a form re-initialization via hasMetadataEnrichment(). This causes checksForErrors() to be called multiple times concurrently. The first call correctly marks form controls as touched, but initForm() then rebuilds the controls, wiping their touched state. The second call is skipped by the isEqual() guard in checkSectionErrors() because this.sectionData.errorsToShow was already updated by the first call, so markAsTouched() is never re-applied to the rebuilt controls. This fix resets this.sectionData.errorsToShow to [] before calling initForm() in the hasMetadataEnrichment branch of updateForm(), so the second checksForErrors() call treats the errors as new and re-applies them to the rebuilt form controls. Co-authored-by: Perplexity AI <noreply@perplexity.ai> https://umd-dit.atlassian.net/browse/LIBDRUM-909
1 parent 5388c7b commit ded240c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/app/submission/sections/form/section-form.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,20 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
370370
this.isUpdating = true;
371371
this.formModel = null;
372372
this.cdr.detectChanges();
373+
// UMD Customization
374+
// Clear errors before calling initForm.
375+
// This is needed because this code path may be called multiple times,
376+
// and checksForErrors does a no-op (essentially clearing the
377+
// validation errors) if the "this.sectionData.errorsToShow" hasn't
378+
// changed.
379+
// Clearing the "errorsToShow" ensures that checkForErrors actually
380+
// shows the errors, no matter how many times this code block is called.
381+
//
382+
// Note: Future DSpace changes may eliminate the need for this change,
383+
// so it should be checked when doing DSpace upgrades, and removed,
384+
// if possible.
385+
this.sectionData.errorsToShow = [];
386+
// End UMD Customization
373387
this.initForm(sectionData, errors, sectionState.serverValidationErrors);
374388
this.checksForErrors(errors);
375389
this.isUpdating = false;

0 commit comments

Comments
 (0)