Synchronize inline records triggers maxItemsError
How to reproduce:
1. Install attached extension.
2. Add new page.
3. Insert "Container" record on the created page.
3.1 Add two content records to "Container" field.
4. Translate the page to another language.
5. Translate the content element with "Translate" mode.
6. Open the container element in default language and attach a third inline content element.
7. Open the translated container element. You will see the third inline content element without translation.
8. Synchronize translated records with "Synchronize with original language"
I see three translated content records.
I see only two content elements afterwards. An error "A maximum of 3 child records are allowed." is triggered. Reloading the page however shows the expected records.
Updated by Andreas Wolf over 3 years ago
- Status changed from New to Accepted
After investigation, I found out that this is indeed a pure JS issue:
- memorizeAddRecord() adds the new element’s ID to the hidden field value, after which isBelowMax() will return false => this is required to remove the control buttons above/below the record list
- domAddNewRecord() is called afterwards, to add the record to the list. Unfortunately, this also uses isBelowMax() to check if the limits have been exceeded. This fails because the hidden field value was extended in the previous call
Unlike I initially suspected, this is in no way related to the placeholder, as far as I can see.
IMO, the best fix for this would be to change isBelowMax and the code that writes to the hidden field to use the actually present records, as these are the source of truth in this case. This would require us to add the record UIDs to the rendered record HTML, but that is really simple, and change the code accordingly. I'm unsure if this would have any additional impact.