Conversation
synchronize FormArray controls with model on reorder, dedupe patch operations by latest op+path, and fix place handling for index 0 to prevent deleted or duplicate values reappearing after save.
There was a problem hiding this comment.
Pull request overview
This PR aims to stabilize repeatable (FormArray-backed) submission form fields by keeping Angular FormArray controls aligned with their corresponding model groups during reorder/delete flows, reducing stale/duplicate JSON Patch operations, and correctly preserving place = 0 when normalizing metadata values.
Changes:
- Align drag/keyboard reorder logic to move both the
DynamicRowArrayModelgroups and the underlyingFormArraycontrols together, removing the stalestartingIndexmapping. - Change JSON Patch operation deduplication to keep only the latest operation per
op+pathacross the whole patch list. - Fix metadata normalization so object-valued array entries correctly keep
place = 0(instead of falling back to a staleplace).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/app/shared/form/builder/form-builder.service.ts | Fixes place derivation so index 0 is preserved for object-valued array entries. |
| src/app/shared/form/builder/form-builder.service.spec.ts | Adds a regression test ensuring place = 0 is preserved for object-valued fields in arrays. |
| src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts | Reorder now uses FormBuilderService.moveFormArrayGroup and drops startingIndex caching so controls/model stay aligned. |
| src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.spec.ts | Adds coverage verifying reorder moves both model groups and FormArray controls together. |
| src/app/core/json-patch/json-patch-operations.reducer.ts | Updates patch dedupe to keep the latest op per op+path globally. |
| src/app/core/json-patch/json-patch-operations.reducer.spec.ts | Updates expectations to match the new “latest op wins” dedupe behavior. |
Document dedupe behavior for json-patch ops
milanmajchrak
requested changes
Mar 26, 2026
Simplify array index presence check
milanmajchrak
approved these changes
Mar 26, 2026
|
Backport branch created but failed to create PR. Please create the PR manually: Or via GitHub CLI: gh pr create --repo dataquest-dev/dspace-angular --base dtq-dev --head ufal:backport-120-to-dtq-dev --title "[Port dtq-dev] stabilize form array reorder/delete behavior" --body "Port of #120 by @amadulhaxxani to `dtq-dev`."(see action log for full error response) |
port-pr bot
pushed a commit
that referenced
this pull request
Mar 26, 2026
* stabilize form array reorder/delete behavior synchronize FormArray controls with model on reorder, dedupe patch operations by latest op+path, and fix place handling for index 0 to prevent deleted or duplicate values reappearing after save. * Document dedupe behavior for json-patch ops Document dedupe behavior for json-patch ops * Simplify array index presence check Simplify array index presence check (cherry picked from commit b261513)
milanmajchrak
pushed a commit
to dataquest-dev/dspace-angular
that referenced
this pull request
Mar 27, 2026
* stabilize form array reorder/delete behavior synchronize FormArray controls with model on reorder, dedupe patch operations by latest op+path, and fix place handling for index 0 to prevent deleted or duplicate values reappearing after save. * Document dedupe behavior for json-patch ops Document dedupe behavior for json-patch ops * Simplify array index presence check Simplify array index presence check (cherry picked from commit b261513) Co-authored-by: Amad Ul Hassan <hassan@ufal.mff.cuni.cz>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
synchronize FormArray controls with model on reorder, dedupe patch operations by latest op+path, and fix place handling for index 0 to prevent deleted or duplicate values reappearing after save.
Problem description
Issue #118 caused repeatable form array values to behave inconsistently after reorder/delete flows. Users could see deleted values reappear or duplicate values persist after save because model row order, FormArray control order, and generated patch operations could diverge.
Analysis
The fix addresses three root causes:
Copilot review