Fix incorrect row count on nested subforms #22757
Merged
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.
Pull request for Issue #22441 (and also #22690 ) - see those issues for testing instructions.
Summary of changes
We were incorrectly using the lastRowNum property inside of the subformRepeatable object due to
legacy reasons (the logic using a lastRowNum property has been overtaken from history, see commit
f2a9874 ).
What happened is that we always were incrementing the lastRowNum property by 1 inside of the
fixUniqueAttributes method, whilest we call that method multiple times recursively, when we have
nested subforms. So having a 2-level subform meant we would increment the lastRowNum twice for every
added row, effectively meaning we would skip certain indices and hence totally lose the connection
between the actual count of existing rows and their index. Actually we do not need the lastRowNum
property, as the current logic works well without it just by calculating the count of rows directly
in the addRow method. So removing the lastRowNum property is the best solution.
@gaelicwinter and @dawe78 can you please this PR? Thanks!