[MGNLUI-4980] Multivalue field doesn't keep order when long list of elements Created: 29/Jan/19  Updated: 21/Mar/23  Resolved: 10/Mar/21

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.0
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: maintenance, multifield, quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Old framework

 Description   

MultivalueField doesn't keep order of its elements when, according to test results, more than 128 elements.

Steps to reproduce:

  1. Insert in multivalue field 128 elements
  2. Change order of the two first elements: it works
  3. Change order of the two last elements: it doesn't keep the order

The cause of the error resides in info.magnolia.ui.form.field.MultiField class when calling switchItemProperties(Object, Object) method after changing the multivalue order. The comparison between identifiers is made with == operator which works fine with the first 127 elements but after that, objects compared are not the same (although they have same values) and therefore, condition is not true and the order is not changed:

info.magnolia.ui.form.field.MultiField.switchItemProperties(Object, Object)
...
if (propertyId == firstPropertyId) {
                        getValue().addItemProperty(firstPropertyId, propertySecond);
                    } else if (propertyId == secondPropertyId) {
                        getValue().addItemProperty(secondPropertyId, propertyFirst);
                    } else {
                        getValue().addItemProperty(propertyId, storedValues.getItemProperty(propertyId));
                    }
...

Switching comparison operator to equals() should fix this issue.



 Comments   
Comment by Roman Kovařík [ 10/Mar/21 ]

Can't reproduce on latest https://demo.magnolia-cms.com/.magnolia/admincentral#app:categories:detail;/tour-types/active:edit

Generated at Mon Feb 12 09:22:01 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.